Matlab实现在理想介质中电磁波传播电磁场分布图

在微波技术实验课程中,我学习了用Matlab绘制电磁场分布图,下面分享给大家。

代码如下

function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% ==================设置电磁场参数====================
u0 = 4*pi*1e-7;         	%真空磁导率
e0 = 1/(36*pi)*1e-9;    		% 自由空间介电常数
z0= sqrt(u0/e0);
k = 2*pi;                   %波阻抗
f=str2double(get(handles.edit3,'String'));
w = 2*pi*f*1e6;           	%电磁波频率
phi = str2double(get(handles.edit2,'String'));               	%初始相位
EE = str2double(get(handles.edit1,'String'));        	%电场振幅
HH = EE/z0;             	%磁场振幅
% ===================设置仿真参数=====================
grid on;
z = 0 : 0.001 : 2 * w / ( pi * 10^8);         		%沿z轴传播
zero=zeros(size(z));
t=0;                    	% t=0时刻传播状态
% ====================建立仿真量=====================
Ex = EE*cos(w*t-k*z+phi);
Hy = HH*cos(w*t-k*z+phi);
% ===========描绘理想介质中t=0时刻波传播状态===========
    %电场
    q=quiver3(z,zero,zero,zero,zero,Ex,'R');
    set(q,'maxheadsize',0);
    hold on;
    %磁场
    q=quiver3(z,zero,zero,zero,Hy,zero,'B');
    set(q,'maxheadsize',0);
    xlabel('电磁场传播方向','fontSize',12);
    ylabel('磁场方向','fontSize',12);
    zlabel('电场方向','fontSize',12);
    title('理想介质平面电磁波传播静态示意图','fontsize',14);
    axis auto;
    set(gca,'fontsize',10);
    hold off;

guidata(hObject, handles);

结果如下图:

Matlab实现在理想介质中电磁波传播电磁场分布图_第1张图片

 

你可能感兴趣的:(matlab)