Write a MATLAB code to visualize 2D the electric field vecto

Write a MATLAB code to visualize (2D) the electric field vector due to finite line charge of length l, placed in free space. The code must ask the user to input the value of the charge density rho_l and the length of the edge l.

Solution

clc; %clear the command line clear;

%remove all previous variables

Q1=;

%charges on Q1 Q2=;

%charges on Q2 pL=;

%charge density of the line Epsilono=8.8419e-12;

%Permitivity of free space P=[];

%coordinates of observation point A=[];

%coordinates of Q1 B=[];

%coordinates of Q2 C=[];

%coordinates of the center of the line charge Number_of_L_Steps=100000;

%the steps of L %%the following routine calculates the electric fields at the %%observation point generated by the point charges R1=P-A;

%the vector pointing from Q1 to the observation point R2=P-B;

%the vector pointing from Q2 to the observation point R1Mag=norm(R1);

%the magnitude of R1 R2Mag=norm(R2);

%the magnitude of R1 E1=Q1/(4*pi*Epsilono*R1Mag^3)*R1;

%the electric field generated by Q1 E2=Q2/(4*pi*Epsilono*R2Mag^3)*R2;

%the electric field generated by Q2 %%the following routine calculates the electric field at the %%observation point generated by the line charge d=norm(P-C);

%the distance from the observation point to the center of the line length=100*d;

%the length of the line dL_V=length/Number_of_L_Steps*[];

%vector of a segment dL=norm(dL_V);

%length of a segment EL=[];

%initialize the electric field generated by EL C_segment=C-( Number_of_L_Steps/2*dL_V-dL_V/2);%the center of the first segment for i=1: Number_of_L_Steps R=P-C_segment;

%the vector seen from the center of the first segment to the observation point RMag=norm(R);

%the magnitude of the vector R EL=EL+dL*pL/(4*pi*Epsilono*RMag^3)*R;

%get contibution from each segment C_segment=C_segment+dL_V;

%the center of the i-th segment end E=E1+E2+EL;% the electric field at P

clc; %clear the command line clear;

%remove all previous variables

Q1=;

%charges on Q1 Q2=;

%charges on Q2 pL=;

%charge density of the line Epsilono=8.8419e-12;

%Permitivity of free space P=[];

%coordinates of observation point A=[];

%coordinates of Q1 B=[];

%coordinates of Q2 C=[];

%coordinates of the center of the line charge Number_of_L_Steps=100000;

%the steps of L %%the following routine calculates the electric fields at the %%observation point generated by the point charges R1=P-A;

%the vector pointing from Q1 to the observation point R2=P-B;

%the vector pointing from Q2 to the observation point R1Mag=norm(R1);

%the magnitude of R1 R2Mag=norm(R2);

%the magnitude of R1 E1=Q1/(4*pi*Epsilono*R1Mag^3)*R1;

%the electric field generated by Q1 E2=Q2/(4*pi*Epsilono*R2Mag^3)*R2;

%the electric field generated by Q2 %%the following routine calculates the electric field at the %%observation point generated by the line charge d=norm(P-C);

%the distance from the observation point to the center of the line length=100*d;

%the length of the line dL_V=length/Number_of_L_Steps*[];

%vector of a segment dL=norm(dL_V);

%length of a segment EL=[];

%initialize the electric field generated by EL C_segment=C-( Number_of_L_Steps/2*dL_V-dL_V/2);%the center of the first segment for i=1: Number_of_L_Steps R=P-C_segment;

%the vector seen from the center of the first segment to the observation point RMag=norm(R);

%the magnitude of the vector R EL=EL+dL*pL/(4*pi*Epsilono*RMag^3)*R;

%get contibution from each segment C_segment=C_segment+dL_V;

%the center of the i-th segment end E=E1+E2+EL;% the electric field at P

 Write a MATLAB code to visualize (2D) the electric field vector due to finite line charge of length l, placed in free space. The code must ask the user to inpu
 Write a MATLAB code to visualize (2D) the electric field vector due to finite line charge of length l, placed in free space. The code must ask the user to inpu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site