رسم نمودار اسمیت با برنامه متلب
کد زیر نمودار اسمیت را رسم می کند :
clear
clc
disp('menu')
disp('1 - z smith chart')
disp('2 - y smith chart')
q=input('press 1 or 2');
% Draw outer circle
t = linspace(0, 2*pi, 100);
x = cos(t);
y = sin(t);
plot(x, y); axis equal;
% Place title and remove ticks from axes
title(' Smith Chart ')
set(gca,'xticklabel',{[]});
set(gca,'yticklabel',{[]});
hold on
%% draw z smith chart
if(q==1)
% Draw circles along horizontal axis
k = 0:0.05:1;
for i = 1 : length(k)
x(i,:) = +k(i)+ (1 - k(i)) * cos(t);
y(i,:) = +(1 - k(i)) * sin(t);
plot(x(i,:), y(i,:), 'k')
end
% Draw partial circles along vertical axis
kt=pi/2:pi/25:2*pi;
for j=1: length(kt)
k(j) = (-cos(kt(j)))/(sin(kt(j))+1);
end
for i = 1 : length(kt)
t = linspace(kt(i), 1.5*pi, 50);
a(i,:) = 1 + k(i)*cos(t);
b(i,:) = k(i)+k(i)*sin(t);
plot(a(i,:), b(i,:),'k:', a(i,:), -b(i,:),'k:' )
end
end
%% draw y smith chart
if(q==2)
% Draw circles along horizontal axis
k = 0:0.05:1;
for i = 1 : length(k)
x(i,:) = -k(i)- (1 - k(i)) * cos(t);
y(i,:) = -(1 - k(i)) * sin(t);
plot(x(i,:), y(i,:), 'k')
end
% Draw partial circles along vertical axis
kt=pi/2:pi/25:2*pi;
for j=1: length(kt)
k(j) = (-cos(kt(j)))/(sin(kt(j))+1);
end
for i = 1 : length(kt)
t = linspace(kt(i), 1.5*pi, 50);
a(i,:) = -1 - k(i) * cos(t);
b(i,:) = -k(i) - k(i) * sin(t);
plot(a(i,:), b(i,:),'k:', a(i,:), -b(i,:),'k:' )
end
end