Trying to draw the electric field produce by 2 parallel charge plates
3 views (last 30 days)
Show older comments
the charge is going from postive to negative and outside the the plates their is no charge the problem is that at edges the feild is not bending can you please help me.
clear; close all; clc;
%Crear grid
N=30;
minX=-2;maxX=+2;
minY=-2;maxY=+2;
x=linspace(minX,maxX,N);
y=linspace(minY,maxY,N);
[xG,yG]=meshgrid(x,y);
%postion of NEGATIVE plate
xn=0.5; yn=0; a=0.4;
%postion of POSTIVE plate
xp=-0.5; yp=0;
%ELECTRIC FIELD
Sn=-20; %NEGATIVE SURFACE CHARGE DENSITY
Sp=+20; %POSTIVE SURFACE CHARGE DENSITY
e0 = 8.854e-12;
k = 1/(2*e0);
Rx = xG - xn;
Ry = 0;
R = sqrt(Rx.^2 + Ry.^2);
%ELECTRIC FIELD BY NEGATIVE CHARGE SHEET
Ex = k .* Sn .* Rx ./ R;
Ey = k .* Sn .* Ry ./ R;
Rx = xG - xp;
Ry = 0;
R = sqrt(Rx.^2 + Ry.^2);
%ELECTRIC FIELD BY POSTIVE CHARGE SHEET
Ex = Ex + k .* Sp .* Rx ./ R;
Ey = Ey + k .* Sp .* Ry ./ R;
E = sqrt(Ex.^2 + Ey.^2);
u = Ex./E;
v = Ey./E;
figure();
h=quiver(xG,yG,u,v,'autoscalefactor',0.5);
set(h,'color',[1 0 0],'linewidth',1.2);
axis equal;
box on
%NEGATIVE PLATE
h=rectangle('Position',[xn-a/2,yn-a/2,a,1]);
set(h,'Facecolor',[0 0 1],'Edgecolor',[0 0 1]);
text(0.43,0.05,'-','Color','white','FontSize',30);
%POSTIVE PLATE
h=rectangle('Position',[xp-a/2,yp-a/2,a,1]);
set(h,'Facecolor',[1 0 0],'Edgecolor',[1 0 1]);
text(-0.6,0,'+','Color','white','FontSize',30);
Answers (1)
See Also
Categories
Find more on Data Import and Network Parameters in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!