资源描述:
《西电电院电磁场与电磁波大作业》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、q=-2/5;xm=4;ym=4;x=linspace(-xm,xm);y=linspace(-ym,ym);[X,Y]=meshgrid(x,y);R1=sqrt((X+1).^2+Y.^2);R2=sqrt((X-1).^2+Y.^2);U=5*(1./R1+q./R2);u=-5:0.3:5;figurecontour(X,Y,U,u)gridonlegend(num2str(u'))holdonplot([-xm;xm],[0;0])plot([0;0],[-ym;ym])plot(-1,0,'o','MarkerSize',1
2、2)plot(1,0,'o','MarkerSize',12)[Ex,Ey]=gradient(-U,x(2)-x(1),y(2)-y(1));dangle1=20;angle1=(dangle1:dangle1:180-dangle1)*pi/180;r0=0.1;x1=r0*cos(angle1)-1;y1=r0*sin(angle1);streamline(X,Y,Ex,Ey,x1,y1)streamline(X,-Y,Ex,-Ey,x1,-y1)dangle2=dangle1/q;angle2=(180-dangle2:-dan
3、gle2:dangle2)*pi/180;x2=r0*cos(angle2)+1;y2=r0*sin(angle2);streamline(X,Y,Ex,Ey,x2,y2)streamline(X,-Y,Ex,-Ey,x2,-y2)axisequaltighttitle('+5电荷和-2电荷的电场线和电位线','fontsize',20)xlabel('itx','fontsize',16)ylabel('ity','fontsize',16)text(-xm,ym-0.5,'电势单位:itkQrm_1','fontsize',
4、16)txt=['电荷比:itQrm_2/itQrm_1='num2str(q)];text(-xm,-ym+0.5,txt,'fontsize',16)z=0:0.03:5;Ex=2*cos(z*2*pi);Ey=2*cos((z+1/4)*2*pi);figure(1)plot3(Ex,z,Ey,'b','linewidth',2);gridonholdonplot3([-2;2],[0;0],[0;0]);plot3([0;0],[0;5],[0;0]);plot3([0;0],[0;0],[-2;2]);axis([-2
5、205-22])xlabel('x轴');ylabel('z轴');zlabel('y轴');title('螺旋线')