三维电磁场的可视化

a=0.35
the=-1:0.04:1
y=-1:0.04:1
z=-1:0.04:1
[Y,Z,T]=meshgrid(y,z,the)
r=sqrt((a*cos(T)).^2+(Y-a*sin(T)).^2+z.^2)
r3=r.^3
dby=a*Z.*sin(T)./r3
by=pi/40*trapz(dby,3)
dbz=a*(a-Y.*sin(T))./r3
bz=pi/40*trapz(dbz,3)
figure(1)
[bSY,bSZ]=meshgrid([0:0.05:0.2],0)
h1=streamline(Y(:,:,1),Z(:,:,1),by,bz,bSY,bSZ,[0.1,1000])
h2=copyobj(h1,gca)
rotate(h2,[1,0,0],180,[0 0 0])
h3=copyobj(allchild(gca),gca)
rotate(h3,[0,1,0],180,[0 0 0])
hold on



title('磁场二维图','FontSize',15)
for kk=1:4
    [bSY,bSZ]=meshgrid(0.2+kk*0.02,0)
    streamline(Y(:,:,1),Z(:,:,1),by,bz,bSY,bSZ,[0.02/(kk+1),4500])
    
xlim([-0.98 0.62])
ylim([-1.02 0.98])
    streamline(-Y(:,:,1),Z(:,:,1),-by,bz,-bSY,bSZ,[0.02/(kk+1),4500])
end
[X,Y,Z]=meshgrid(-0.5:0.04:0.5)
r2=X.^2+Y.^2+Z.^2
for k =1:81
    phi=pi/40*(k-1)
    costh=cos(phi)
    sinth=sin(phi)
    R3=(r2+a^2-2*a*(X*costh+Y*sinth)).^(3/2)
    Bx0(:,:,:,k)=a*Z*costh./R3
    By0(:,:,:,k)=a*Z*sinth./R3
    Bz0(:,:,:,k)=a*(a-X*costh-Y*sinth)./R3
   
end
Bx=pi/40*trapz(Bx0,4)
By=pi/40*trapz(By0,4)
Bz=pi/40*trapz(Bz0,4)
figure(2)
v=[-0.2,-0.1,0,0.1,0.2]
[Vx,Vy,Vz]=meshgrid(v,v,0)
plot3(Vx(:),Vy(:),Vz(:),'r*')
streamline(X,Y,Z,Bx,By,Bz,Vx,Vy,Vz,[0.1,2000])
hold on
plot3(-Vx(:),-Vy(:),-Vz(:),'r*')
streamline(-X,-Y,-Z,-Bx,-By,-Bz,-Vx,-Vy,-Vz,[0.1,2000])
hold on
axis([-0.5,0.5,-0.5,0.5,-0.5,0.5])
view(-23,26)
box on
title('','fontsize',15)
t=0:pi/100:2*pi
plot(a*exp(i*t),'r-','LineWidth',3)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值