- #1
Esoremada
- 52
- 0
Homework Statement
I am trying to graph the flux density field between two infinite line charges located at y = 1 and y = -1
Homework Equations
I am trying to do it using the equation for a line charge that I got from lecture notes.
The above equation is derived from this:
Here is the proof http://puu.sh/g4E0V/68d2790871.png
My friend successfully graphed the field using this equation and using a nested loop to sum the pieces of the line up at each point, but I chose another way and am having trouble.
The Attempt at a Solution
I tried doing it by solving using the line charge field equation at every point rather than using a loop, but ended up with a different wrong result. This is my code.
In my code what I call x and y are respectively z and p in that yellow diagram above.
min = -5;
max = 5;
num = 50;
step = (max - min) / (num-1);
[X,Y]=meshgrid(-5:step:5,-5:step:5);%build arrays of plot space
Fx=zeros(num,num);%x component of flux density
Fy=zeros(num,num);%y component of flux density
pL1=1e-6;%top line charge density
pL2=-1e-6;%bottom line charge density
for i=1:num
for j=1:num
%cos = x / h
%sin = y / h
x = X(i,j);
y = Y(i,j);
Fy(i,j) = (pL1 / (2*pi*(y-1))) * 1;
Fx(i,j) = (pL1 / (2*pi*(y-1))) * 0;
Fy(i,j) = Fy(i,j) + (pL2 / (2*pi*(y+1))) * 1;
Fx(i,j) = Fx(i,j) + (pL2 / (2*pi*(y+1))) * 0;
end
end
quiver(X,Y,Fx,Fy)
Last edited by a moderator: