官方淘宝店 易迪拓培训 旧站入口
首页 > 微波射频 > 射频工程师交流 > 怎么用matlab对传输线的阻抗匹配进行仿真?

怎么用matlab对传输线的阻抗匹配进行仿真?

12-12
唉 以前没学过这方面的  

以前随手写的,不过有错误(波的原理性错误),需要修改才对
a=1;
b=0;
s=a*exp(j*b/180*pi);
f=2e9;
lemada=4e8/f;
t=0:0.01e-9:4e-9;
z=-1+0.005:0.005:0;
wave_in=zeros(200,401);
wave_re=zeros(200,401);
for n=1:100
    temp=2*n;
    wave_in(1:temp,n)=exp(j*(2*pi*f*t(n)-2*pi/lemada*z(1:temp)'));
end;
for n=101:401
    wave_in(:,n)=exp(j*(2*pi*f*t(n)-2*pi/lemada*z'));
end;
for n=1:100
    temp=200-2*n+2;
    wave_re(temp:200,100+n)=exp(j*(2*pi*f*t(n)+2*pi/lemada*z(temp:200)'))*s;
end;
for n=201:401
    wave_re(:,n)=exp(j*(2*pi*f*t(n)+2*pi/lemada*z'))*s;
end;
wave=wave_in+wave_re;
wave_RE=real(wave);
for k = 1:401
   L{k} =real(wave(:,k));
end

% Set graphics parameters.
fig = figure;
set(fig,'color','k')
h = plot(z,L{1},'w');
% [a,e] = view; view(a+270,e);
axis([-1 0 -2 2]);
axis off;
% Buttons
uicontrol('pos',[70 10 60 20],'string','close','fontsize',12, ...
   'callback','close(gcbf)');
uicontrol('pos',[130 10 60 20],'string','play','fontsize',12, ...
   'callback','set(gcbf,''userdata'',1)');
uicontrol('pos',[190 10 60 20],'string','pause','fontsize',12, ...
   'callback','set(gcbf,''userdata'',0)');
uicontrol('pos',[250 10 60 20],'string','reset','fontsize',12, ...
   'callback','set(gcbf,''userdata'',2)');
uicontrol('pos',[310 10 60 20],'string','reback','fontsize',12, ...
   'callback','set(gcbf,''userdata'',3)');
uicontrol('pos',[370 10 60 20],'string','faster','fontsize',12, ...
   'callback','set(gcbf,''userdata'',4)');
uicontrol('pos',[430 10 60 20],'string','slower','fontsize',12, ...
   'callback','set(gcbf,''userdata'',5)');
dt = 10000000;
k=1;
m=2;
set(fig,'userdata',m)
% Run
while ishandle(fig)    
    
    if get(fig,'userdata')==4
        dt=1/2*dt;
        set(fig,'userdata',1);
    elseif get(fig,'userdata')==5
        dt=2*dt;
        set(fig,'userdata',1);
    end;
    i=dt;
    while i>0
        i=i-1;
    end;
    if get(fig,'userdata')==1
        k=k+1;
    elseif get(fig,'userdata')==2
        k=1;
    elseif get(fig,'userdata')==3
        if k>10
            k=k-10;
        else
            k=1;
        end;
        set(fig,'userdata',0);
    end;
    if get(fig,'userdata')==2
        k=k+1;
    end;
    if k==402;
        k=201;
    end;
    A =L{k};
    
    % Surface plot of y axis
    set(h,'ydata',A);
    drawnow
end;

Top