资源描述:
《实验八 点电荷电场分布模拟MATLAB程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、电力线图>>Q1=1,Q2=-4,d=2;x=-5:0.1:5;y=-5:0.1:5;[X,Y]=meshgrid(x,y);R1=sqrt(X.^2+(Y-d./2).^2);R2=sqrt(X.^2+(Y+d./2).^2);Z=Q1*(Y-d./2)./R1+Q2*(Y+d./2)./R2;C=-5:0.22:5;holdon[S,h]=contour(X,Y,Z,C);clabel(S);plot(0,d/2,'marker','o','markersize',10,'markerfacecolor','g','markeredgecolo
2、r','g');text(0,d/2,'+','fontsize',20);plot(0,-d/2,'marker','o','markersize',10,'markerfacecolor','g','markeredgecolor','g');text(0,-d/2,'-','fontsize',20);gridon,title('电力线图');电势分布图>>Q1=1,Q2=-4,d=2;x=-5:0.1:5;y=-5:0.1:5;[X,Y]=meshgrid(x,y);R1=sqrt(X.^2+(Y-d./2).^2);R2=sqrt(X.^
3、2+(Y+d./2).^2);Z=(Q1./R1)+(Q2./R2);C=-4:0.55:1;[S,h]=contour(X,Y,Z,C);clabel(S);holdonplot(0,d/2,'marker','o','markersize',10,'markerfacecolor','g','markeredgecolor','g');text(0,d/2,'+','fontsize',20);plot(0,-d/2,'marker','o','markersize',10,'markerfacecolor','g','markeredgeco
4、lor','g');text(0,-d/2,'-','fontsize',20);gridon,title('电势分布图');电场矢量图>>Q1=1,Q2=-4,d=2;x=-5:0.1:5;y=-5:0.1:5;[X,Y]=meshgrid(x,y);R1=sqrt(X.^2+(Y-d./2).^2);R2=sqrt(X.^2+(Y+d./2).^2);Z=(Q1./R1)+(Q2./R2);C=-4:0.55:1;[Ex,Ey]=gradient(-Z);E=sqrt(Ex.^2+Ey.^2);Ex=Ex./E,Ey=Ey./E;holdon;
5、plot(0,d/2,'marker','o','markersize',10,'markerfacecolor','g','markeredgecolor','g');text(0,d/2,'+','fontsize',20);plot(0,-d/2,'marker','o','markersize',10,'markerfacecolor','g','markeredgecolor','g');text(0,-d/2,'-','fontsize',20);holdon;H=quiver(X,Y,Ex,Ey,0.5)gridon,title('电
6、场矢量图');