تطبیق امپدانس با استفاده از برنامه متلب
کد زیر برای تطبیق امپدانسی با استفاده از استاب موازی و سری برای حالت های اتصال کوتاه و مدار باز استفاده می شود .
% AmirHosein
HajiHoseini
close all
clear
clc
disp('menu')
disp('1 - paralell stubs')
disp('2 - sery stubs')
q=input('select 1 or 2 \n');
z=input('please enter Zl :');
zl=z/50 ; % normalaizing Zl
%% 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
% ??? ????? ??? real
k = 0:0.1:1;%k=r/(1-r);r=real(zl)
for j = 1 : length(k)
x(j,:) = +k(j)+ (1 - k(j)) * cos(t);
y(j,:) = +(1 - k(j)) * sin(t);
plot(x(j,:), y(j,:), 'k')
end
% ??? ????? ??? image
kt=pi/2:pi/10:2*pi;%???? ????? ????? ???? ?????? ??? image
for j=1: length(kt)
k(j) = (-cos(kt(j)))/(sin(kt(j))+1);%k=1/x;x=image(zl)
end
for j = 1 : length(kt)
t = linspace(kt(j), 1.5*pi, 50);
a(j,:) = +1 + k(j) * cos(t);
b(j,:) = +k(j) + k(j) * sin(t);
plot(a(j,:), b(j,:),'k:', a(j,:), -b(j,:),'k:' )
end
%% calculations for paralell stubs
if q==1
% plotting circle of Zl
g=(zl-1)./(zl+1);%?????? ????
g1=abs(g);
t = linspace(0, 2*pi, 100);
c = g1.*cos(t);
d = g1.*sin(t);
plot(c, d,'r','LineWidth',2); axis equal; % ??? ????? ?? ????zl
%plot circlr g=1
e = 0.5+ (1 - 0.5) * cos(t);
f = 0.5 * sin(t);
plot(e, f, 'c','LineWidth',2)
% calculating d
p1=g1^2+1i.*(g1*sqrt(1-g1^2));%???? ????? ????? g=1 ? ????? ?? ????zl
p2=g1^2+1i.*-g1*sqrt(1-g1^2);
d1=abs(angle(p1)-angle(zl))/(4*pi);
disp('d1/landa =')
disp(d1)
d2=abs(angle(p2)-angle(zl))/(4*pi);
disp('d2/landa =')
disp(d2)
% calculating L
disp('for s.c stub the answers are :')
m=(1i)/(g1*sqrt(1-g1^2));%convert p1 to admitance
p5=(m-1)./(m+1);
l1=abs(angle(p5)-pi)/(4*pi);
disp('L1/landa=')
disp(l1)
n=(1i)/(-g1*sqrt(1-g1^2));%convert p2 to admitance
p6=(n-1)./(n+1);
l2=abs(angle(p6)-pi)/(4*pi);
disp('L2/landa=')
disp(l2)
disp('for o.c stub the answers are :')
l3=l1+0.25;
l4=l2+0.25;
disp('L3/landa=')
disp(l3)
disp('L4/landa=')
disp(l4)
p3=-p1;
p4=-p2;
%% plotting
plot(real(g),imag(g), 'b.', 'markersize',18);
plot(real(p1),imag(p1), 'b.', 'markersize',18);
plot(real(p2),imag(p2), 'b.', 'markersize',18);
plot(real(p3),imag(p3), 'b.', 'markersize',18);
plot(real(p4),imag(p4), 'b.', 'markersize',18);
plot(real(p5),imag(p5), 'b.', 'markersize',18);
plot(real(p6),imag(p6), 'b.', 'markersize',18);
plot([0 real(g)],[0 imag(g)],'m','LineWidth',2)
plot([real(p1) real(p3)],[imag(p1) imag(p3)],'k','LineWidth',3)
plot([real(p2) real(p4)],[imag(p2) imag(p4)],'b','LineWidth',3)
plot([0 real(p5)],[0 imag(p5)],'g','LineWidth',2)
plot([0 real(p6)],[0 imag(p6)],'g','LineWidth',2)
end
%% calculations for sery stubs
if q==2
% plotting circle of Zl
g=(zl-1)./(zl+1);
g1=abs(g);
t = linspace(0, 2*pi, 100);
c = g1.*cos(t);
d = g1.*sin(t);
plot(c, d,'r','LineWidth',2); axis equal;
%plot circlr g=1
e = 0.5+ (1 - 0.5) * cos(t);
f = 0.5 * sin(t);
plot(e, f, 'c','LineWidth',2)
% calculating d
p1=g1^2+1i.*(g1*sqrt(1-g1^2));
p2=g1^2+1i.*-g1*sqrt(1-g1^2);
d1=abs(angle(p1)-angle(zl))/(4*pi);
disp('d1/landa =')
disp(d1)
d2=abs(angle(p2)-angle(zl))/(4*pi);
disp('d2/landa =')
disp(d2)
% calculating L
disp('for s.c stub the answers are :')
m=imag(p2);
%????? ???? ????? ??????
p5=(-1i*m-1)./(-1i*m+1);
l1=abs(angle(p5)-pi)/(4*pi);
disp('L1/landa=')
disp(l1)
n=-m;
%????? ???? ????? ??????
p6=(-1i*n-1)./(-1i*n+1);
l2=abs(angle(p6)-pi)/(4*pi);
disp('L2/landa=')
disp(l2)
disp('for o.c stub the answers are :')
l3=l1+0.25;
l4=l2+0.25;
disp('L3/landa=')
disp(l3)
disp('L4/landa=')
disp(l4)
%% plotting
plot(real(g),imag(g), 'b.', 'markersize',18);
plot(real(p1),imag(p1), 'b.', 'markersize',18);
plot(real(p2),imag(p2), 'b.', 'markersize',18);
plot(real(p5),imag(p5), 'b.', 'markersize',18);
plot(real(p6),imag(p6), 'b.', 'markersize',18);
plot([0 real(g)],[0 imag(g)],'m','LineWidth',2)
plot([real(p1) 0],[imag(p1) 0],'k','LineWidth',3)
plot([real(p2) 0],[imag(p2) 0],'b','LineWidth',3)
plot([0 real(p5)],[0 imag(p5)],'g','LineWidth',2)
plot([0 real(p6)],[0 imag(p6)],'g','LineWidth',2)
end
salam