|
"george veropoulos" <veropgr@yahoo.gr> wrote in message <jmjdk1$s02$1@newscl01ah.mathworks.com>...
> Dear Friends
> I m looking a matlab program or a matlab function
> to produce the electric field line of various number electric
> points charges...
>
Easy enough. Here the charges are in a 2D plane:
n = 5; % number of charges
% locations
x=rand(n,1)-0.5;
y=rand(n,1)-0.5;
% charge
q = rand(n,1);
q = q - mean(q);
% Coulumb's number
ke = 8.9875517873681764e9;
xi = linspace(-1,1,33);
yi = linspace(-1,1,33);
[XI YI] = meshgrid(xi,yi);
zi = complex(XI,YI);
z = complex(x,y);
[ZI Z]=ndgrid(zi(:),z(:));
dZ = ZI-Z;
Zn = abs(dZ);
% http://en.wikipedia.org/wiki/Electric_field
E = (dZ./Zn.^3)*(q(:)*ke);
E = reshape(E, size(XI));
En = abs(E);
Ex = real(E);
Ey = imag(E);
figure
quiver(XI,YI,Ex./E,Ey./E);
hold on
plot(x, y, 'or')
axis equal
% Bruno
|