【电磁】基于Matlab模拟圆柱形永磁体的磁场情况

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机

⛄ 内容介绍

针对"电磁场与电磁波"课程教学中电磁波传播的教学难点,提出利用MATLAB实现圆柱形永磁体的磁场情况的仿真模拟,得到空间各点电场和磁场矢量随时间的变化规律.通过MATLAB可以实现圆柱形永磁体的实时图形,可以将难理解的知识和现象生动,形象地呈现出来,便于理解理论知识,起到良好的教学效果.

⛄ 部分代码

%% Ring magnetic field visualization

 % This script is a DEMO for the visualization of the magnetic flux density 

 % field lines of an axially magnetized ring. 

clc

clear all %#ok<CLALL>

close all

%%

MagPos = [0 0 0 0 0 1];

M = 1.2706/(4*pi*1e-7);              % Magnetization   [A/m]    

L = 0.006;

Rin  = 0.002;

Rout = 0.006;

spaceRegion = -0.1:0.001:0.1;

x = spaceRegion; z = x;

Npoints = length(x);

k = 1;

Brho = zeros(Npoints,Npoints); Baxial = Brho; B = Brho;

for i = 1:Npoints

    for j = 1:Npoints

        

        Point = [x(j) 0 z(i)];

        

        [Bx, By, Bz] = WrapRingBfield3(Rin,Rout,L,M,MagPos',Point');

        

        Brho(i,j)   = Bx;

        Baxial(i,j) = Bz;

        B(i,j)      = sqrt(Bx^2+Bz^2);

        

    end

end

%% planar field lines

D = Rout*2;

figure(1)

subplot(121)

plot_field = streamslice(x,z,Brho,Baxial,'method','cubic');

set(plot_field,'Color','black','LineWidth',1.2);

hold on

rectangle('Position',[0-D/2,0-L/2,D,L],'FaceColor',[0.2 0.2 0.2],...

    'EdgeColor',[0 0 0],'LineWidth',1)

hold on

rectangle('Position',[0-D/2,0-L/2,D,L/2],'FaceColor',[0 0 1])

hold on

rectangle('Position',[0-D/2,0,D,L/2],'FaceColor',[1 0 0])

subplot(122)

plot_field = streamslice(x,z,Brho,Baxial,'method','cubic');

set(plot_field,'Color','black','LineWidth',1.2);

hold on

rectangle('Position',[0-D/2,0-L/2,D,L/2],'FaceColor',[0 0 1])

hold on

rectangle('Position',[0-D/2,0,D,L/2],'FaceColor',[1 0 0])

axis([-0.04 0.04 -0.04 0.04])

%% Contour lines (logscale)

[xx,zz] = meshgrid(x);

step = 15;

figure(2) 

contourf(xx,zz,log10(B),1000,'EdgeColor','none')

colormap(jet)

colorbar

hold on 

h = streamline(xx,zz,Brho,Baxial,...

    xx(1:step:end,1:step:end),zz(1:step:end,1:step:end));

rectangle('Position',[0-D/2,0-L/2,D,L/2],'FaceColor',[0 0 1])

rectangle('Position',[0-D/2,0,D,L/2],'FaceColor',[1 0 0])

set(h,'Color','red');

% axis([-0.05 0.05 -0.05 0.05])

title('\textbf{Ring Magnet Model Field Lines}','interpreter','latex',...

    'fontsize',14)

xlabel('x [m]','interpreter','latex')

ylabel('z [m]','interpreter','latex')

⛄ 运行结果

⛄ 参考文献

[1]郑颖, 徐晓梅. 基于MATLAB的带电粒子在电磁场中的运动模拟[J]. 物理通报, 2017(1):6.

[2]肖汉光, 丁朝远, 王颖. 电磁波传播的MATLAB仿真教学实践[J]. 吉林教育, 2017(38):1.

❤️ 关注我领取海量matlab电子书和数学建模资料

❤️部分理论引用网络文献,若有侵权联系博主删除

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值