📄 smith_chart.m
字号:
function out1 = smith_chart(Action,In1,In2,In3,In4)
% function out1 = smith_chart(Action,In1,In2,In3,In4)
% Action = 'draw'
% In1 = [rvalues];
% In2 = [xvalues];
% In3 = Zo of line (optional)
% In4 = position (optional)
NSEGSc = 63;
if strcmp(Action,'draw')
if nargin <=3
Zo = 50;
else
Zo = In3;
end;
if nargin <=4
out1=axes('box','off','xgrid','off','ygrid','off','zgrid','off',...
'color','none','nextplot','add','visible','off');
else
out1=axes('Units','pixels','position',In4,'box','off','xgrid','off','ygrid','off','zgrid','off',...
'color','none','nextplot','add','visible','off');
end;
set(out1,'xlim',[-1.1 1.1],'ylim',[-1.1,1.1]);
xlabel('');
ylabel('');
theta = linspace(-pi, pi, NSEGSc);
for r=(In1)
z =((r/(r+1) + 1/(r+1)*exp(j*theta)));
line('xdata',real(z),'ydata',imag(z),'color',[0.5 0.5 0]);
xpos = (r-1)/(r+1);
h=text(xpos, 0, ftoa('%4w',r*Zo));
% h=text(xpos, 0, sprintf('%4.1f',r*Zo));
set(h, 'VerticalAlignment', 'top', 'HorizontalAlignment', 'right','color',[1 1 1]);
end;
% draw unit circle , and imag==0 line
z = exp(j*theta);
line('xdata',real(z),'ydata',imag(z),'color',[1 1 0]);
line('xdata',[-1 1],'ydata',[0 0],'color',[1 1 0]);
v = linspace(0,10,NSEGSc);
r = [ 0 v.^2];
for x = In2
z = r+j*x*ones(1,NSEGSc+1);
g = (z-1)./(z+1);
line('xdata',real(g),'ydata', imag(g), 'color',[0 0.5 0.5]);
line('xdata',real(g),'ydata',-imag(g), 'color',[0 0.5 0.5]);
g= ((j*x-1)/(j*x+1));
xpos = real(g);
ypos = imag(g);
s = ftoa('%4w',Zo*x);
h=text([xpos xpos], [ypos -ypos], [' j' s ; '-j' s]);
set(h(1),'VerticalAlignment', 'bottom','color',[1 1 1]);
set(h(2),'VerticalAlignment', 'top','color',[1 1 1]);
if xpos == 0
set(h, 'Horizontalalignment', 'center');
elseif xpos < 0
set(h, 'Horizontalalignment', 'right');
end
end;
rmin = min(In2);
rmax = max(In2);
line('xdata',[(rmin-1)/(rmin+1),(rmax-1)/(rmax+1)],'ydata',[0 0],'color',[1 1 0]);
else
end;
% end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -