matlab - Plotting Vector field of a point charge -
i have been trying model electric field of point charge using quiver command.
x=-5:0.5:5; y=-5:0.5:5; [xx,yy]=meshgrid(x,y); r=(xx.^2+yy.^2).^0.5; quiver(x,y,xx./r^3, yy./r^3,1);
the resultant electric field follows,
as can see length of vector increases move away charge (center). learned length of vector plotted quiver depends on magnitude of vector @ point. since electric field reduces move away, 1 expect length of vector should reduce away charge. tried understand or remedy not find anything.
can explain why happening or how can fixed.
thanks time. appreciated.
quite simple fix actually. forgot 2 dots.
x=-5:0.5:5; y=-5:0.5:5; [xx,yy]=meshgrid(x,y); r=(xx.^2+yy.^2).^0.5; quiver(x,y,xx./r.^3, yy./r.^3,1); %% <--- note additional . in front of ^
Comments
Post a Comment