How to solve Microwave Engineering Pozar chapter 5 exercise 3 with MATLAB

Published by John_2016 in the blog How to solve Microwave Engineering Pozar examples and exercises with MATLAB. Views: 110


Question:

[​IMG]

Literature source [POZAR] is available here:
https://www.amazon.co.uk/Microwave-Engineering-David-M-Pozar/dp/0470631554

There's a hand written solutions manual available here:
https://www.scribd.com/doc/176505749/Microwave-engineering-pozar-4th-Ed-solutions-manual


Answer:

[​IMG]

MATLAB code: blue bold font.
MATLAB console results: blue font.
MATLAB comments: green font.
Internet links: light blue underlined font.


Attached .zip pack including:
  • the question
  • MATLAB script pozar_05_exercise_03.m
  • explanation in Adobe format pozar_05_exercise_03.pdf
  • all support functions needed to run the main MATLAB script

Single shunt open circuit stub with transmission line, both stub and transmission line with Z0=75, to match ZL=100+1j*80.

[​IMG]

Matching with transmission line and shunt-stub requires calculating 2 transmission line lengths, expressed in multiples of wavelength:

beta*L=2*pi/lambda*lambda*D=2*pi*D

D is wavelength multiple, or the wave phase angle, that is also the halved angle measured on Smith chart.

1.- the length of the TL where the shunt is placed: D_TL
2.- the length of the parallel shunt stub itself: D_oc_stub


There are 2 solutions, towards generator, CW, along SWR circle, until

real(Zin)==Z0

Now, graphically getting the 1st length of the transmission line

clc;clear all; close all
Z0=75; ZL=100+1j*80;
sm1=smithchart; ax=gca; hold all;
gamma_ZL=(ZL-Z0)/(ZL+Z0);

plot(ax,real(gamma_ZL),imag(gamma_ZL),'o','Color',[1 0 0])
% ZL
YL=1/ZL
gamma_YL=-gamma_ZL
gamma_YL_angle=angle(gamma_YL);gamma_YL_mod=abs(gamma_YL)
if gamma_YL_angle<0 gamma_YL_angle=2*pi+gamma_YL_angle; end
if gamma_YL_angle>(2*pi) gamma_YL_angle=gamma_YL_angle-2*pi; end
Smith_plotY(ax,YL,1/Z0)
Smith_plotRefLine2PhaseCircle(ax,YL,1/Z0,[.6 1 .6])
[x_swr,y_swr]=Smith_plotGammaCircle(ax,ZL,Z0,[1 .6 .6])
[g1x,g1y]=pol2cart(gamma_YL_angle,gamma_YL_mod)
[xr1,yr1]=Smith_plotRcircle(ax,Z0,Z0,[0 0 1])
[xint,yint]=intersections(x_swr,y_swr,xr1,yr1);
plot(ax,xint,yint,'go')
gb1=xint(1)+1j*yint(1);
gb1_angle=angle(gb1);gb1_mod=abs(gb1)
if gb1_angle<0 gb1_angle=2*pi+gb1_angle; end
if gb1_angle>(2*pi) gb1_angle=gb1_angle-2*pi; end
Yb_1=(1/Z0*(1-gb1)/(1+gb1)) %^-1
1/Yb_1 % check real(Z) spot on r=1 circle
Smith_plotRefLine2PhaseCircle(ax,1/Yb_1,Z0,[.6 1 .6])
da=1/100;arc1=da
a0=gamma_YL_angle;a1=gb1_angle;gamma_mod=gamma_YL_mod
while abs(a0-a1)>.01
a0=a0-da;arc1=arc1+da;

if a0<0 a0=2*pi+a0; end
% avoid negative angle
if a0>(2*pi) a0=a0-2*pi; end
gamma=gamma_mod*(cos(a0)+1j*sin(a0));
plot(ax,real(gamma),imag(gamma),'ro','LineWidth',1.5); % drawnow
end
plot(ax,xint,yint,'go')


[​IMG]

Checking that stub is already on r=1 (r=R/Z0) circle

1/Yb_1

=
75.009858443284173 -72.565629355776338i


isequal(Yb_1,gamma2z(-gb1,1/Z0))
=

1

D1_TL_lambda=arc1/(4*pi)

=
0.406640879599787


D1_TL_angle_rad=arc1/2

=
2.554999999999968


D1_TL_angle_deg=arc1*90/pi

=
1.463907166559235e+02



The 2nd transmission line length:

clc;clear all; close all
Z0=75; ZL=100+1j*80;
sm1=smithchart; ax=gca; hold all;
gamma_ZL=(ZL-Z0)/(ZL+Z0);

plot(ax,real(gamma_ZL),imag(gamma_ZL),'o','Color',[1 0 0])
% ZL
YL=1/ZL
gamma_YL=-gamma_ZL
gamma_YL_angle=angle(gamma_YL);gamma_YL_mod=abs(gamma_YL)
if gamma_YL_angle<0 gamma_YL_angle=2*pi+gamma_YL_angle; end
if gamma_YL_angle>(2*pi) gamma_YL_angle=gamma_YL_angle-2*pi; end
Smith_plotY(ax,YL,1/Z0)
Smith_plotRefLine2PhaseCircle(ax,YL,1/Z0,[.6 1 .6])
[x_swr,y_swr]=Smith_plotGammaCircle(ax,ZL,Z0,[1 .6 .6])
[g1x,g1y]=pol2cart(gamma_YL_angle,gamma_YL_mod)
[xr1,yr1]=Smith_plotRcircle(ax,Z0,Z0,[0 0 1])
[xint,yint]=intersections(x_swr,y_swr,xr1,yr1);
plot(ax,xint,yint,'go')
gb2=xint(1)+1j*yint(1);
gb2_angle=angle(gb2);gb2_mod=abs(gb2)
if gb2_angle<0 gb2_angle=2*pi+gb2_angle; end
if gb2_angle>(2*pi) gb2_angle=gb2_angle-2*pi; end
Yb_2=(1/Z0*(1-gb2)/(1+gb2)) %^-1

1/Yb_2 % check real(Z) spot on r=1 circle
Smith_plotRefLine2PhaseCircle(ax,1/Yb_1,Z0,[.6 1 .6])
da=1/100;arc2=da
a0=gamma_YL_angle;a1=gb2_angle;gamma_mod=gamma_YL_mod
while abs(a0-a1)>.01
a0=a0-da;arc2=arc2+da;

if a0<0 a0=2*pi+a0; end
% avoid negative angle
if a0>(2*pi) a0=a0-2*pi; end
gamma=gamma_mod*(cos(a0)+1j*sin(a0));
plot(ax,real(gamma),imag(gamma),'ro','LineWidth',1.5);
% drawnow
end
plot(ax,xint,yint,'go')


[​IMG]

Again check series transmission line has shifted impedance to r=1:

1/Yb_2

isequal(Yb_2,gamma2z(-gb2,1/Z0))


D2_TL_lambda=arc2/(4*pi)

D2_TL_angle_rad=arc2/2

D2_TL_angle_deg=arc2*90/pi


1/Yb_2 =
75.009858443284173 +72.565629355776380i

=
1

D1_TL_lambda =
0.228387343336868

D1_TL_angle_rad =
1.434999999999

D1_TL_angle_deg =
82.219443601272644



Now the OC shunt stubs

Calculating stub lenght Dstub1

hf(3)=figure(3);sm(3)=smithchart; ax(3)=hf(3).CurrentAxes; hold(ax(3),'on');
plot(ax(3),real(gamma_ZL),imag(gamma_ZL),'o','Color',[1 0 0])
gamma_YL_angle=angle(gamma_YL);gamma_YL_mod=abs(gamma_YL)
if gamma_YL_angle<0 gamma_YL_angle=2*pi+gamma_YL_angle; end
if gamma_YL_angle>(2*pi) gamma_YL_angle=gamma_YL_angle-2*pi; end
Smith_plotY(ax(3),YL,1/Z0)


Smith_plotRefLine2PhaseCircle(ax(3),YL,1/Z0,[.2 .6 .2])
[x_swr,y_swr]=Smith_plotGammaCircle(ax(3),ZL,Z0,[1 .6 .6])


[g1x,g1y]=pol2cart(gamma_YL_angle,gamma_YL_mod)
[xr1,yr1]=Smith_plotRcircle(ax(3),Z0,Z0,[0 0 1])
[xint,yint]=intersections(x_swr,y_swr,xr1,yr1,1);
plot(ax(3),xint,yint,'go')


gb1=xint(1)+1j*yint(1);gb1_angle=angle(gb1);gb1_mod=abs(gb1)
if gb1_angle<0 gb1_angle=2*pi+gb1_angle; end
if gb1_angle>(2*pi) gb1_angle=gb1_angle-2*pi; end


yb_1=1/Z0*((1+gb1)/(1-gb1))^-1
1/yb_1
% check already on r=1
Smith_plotRefLine2PhaseCircle(ax(3),1/yb_1,Z0,[.2 .8 .2]) % 1st intersection

gstub=conj(gb1) % where Zin has to move next
plot(ax(3),real(gstub),imag(gstub),'bo')
Zbs=(1/Z0*(1-gstub)/(1+gstub)) ^-1
% using Z Smith chart values
Zbs2=1j*imag(Zbs)
refl_Zstub=(Z0-Zbs2)/(Z0+Zbs2)
refl_Ystub=-refl_Zstub
plot(ax(3),real(refl_Ystub),imag(refl_Ystub),'ro')


Smith_plotRefLine2PhaseCircle(ax(3),Zbs2,Z0,[.2 .2 .8])
Smith_plotBarc(ax(3),Zbs,Z0,[1 0 1])




[​IMG]

da=1/100;a_stub=[angle(refl_Ystub): -da: -pi];arc_stub1=da;
for k=1:1:numel(a_stub)
gamma_stub=cos(a_stub)+1j*sin(a_stub);
arc_stub1=arc_stub1+da;
plot(ax(3),real(gamma_stub),imag(gamma_stub),'bo','LineWidth',1.5);
end
arc_stub1=arc_stub1-da;


[​IMG]

directly from the intersection points

Dstub1_lambda=abs(-pi-angle(gstub))*.25/pi

electric length of OC stub

Dstub1_angle_rad=abs(-pi-angle(gstub))/2
Dstub1_angle_deg=abs(-pi-angle(gstub))*90/pi


from the arc on Smith chart

arc_stub1*180/pi
arc_stub1_lambda=.25/pi*arc_stub1


same as

Dstub1_lambda=arc_stub1/(4*pi)
Dstub1_angle_deg= arc_stub1/2*360/(2*pi)


While operating the equations, decision points keep showing up where signs have to be discerned.

Yet, reading the covered arc, from the intersection point to Y Smith chart Open Circuit -1+0*1j, it's simple and straight to get how long the stub has to be.

Dstub1_lambda = 0.160864794588070
Dstub1_angle_rad = 1.010743313798222
Dstub1_angle_deg = 57.911326051705117
arc_stub1_lambda = 0.377992989843247
Dstub1_lambda = 0.377992989843247
Dstub1_angle_deg = 1.360774763435689e+02



Calculating stub lenght Dstub2

hf(4)=figure(4);sm(4)=smithchart; ax(4)=hf(4).CurrentAxes; hold(ax(4),'on');
plot(ax(4),real(gamma_ZL),imag(gamma_ZL),'o','Color',[1 0 0])

Smith_plotY(ax(4),YL,1/Z0)

Smith_plotRefLine2PhaseCircle(ax(4),YL,1/Z0,[.2 .6 .2])
[x_swr,y_swr]=Smith_plotGammaCircle(ax(4),ZL,Z0,[1 .6 .6])

[g1x,g1y]=pol2cart(gamma_YL_angle,gamma_YL_mod)

[xr1,yr1]=Smith_plotRcircle(ax(4),Z0,Z0,[0 0 1])
[xint,yint]=intersections(x_swr,y_swr,xr1,yr1,1);
plot(ax(4),xint,yint,'go')

gb2=xint(2)+1j*yint(2);gb2_angle=angle(gb2);gb2_mod=abs(gb2)
if gb2_angle<0 gb2_angle=2*pi+gb2_angle; end
if gb2_angle>(2*pi) gb2_angle=gb2_angle-2*pi; end

Yb_2=1/Z0*((1+gb2)/(1-gb2)) ^-1
1/Yb_2
% check already on r=1
Smith_plotRefLine2PhaseCircle(ax(4),1/Yb_2,Z0,[.2 .8 .2])

gstub=conj(gb2)
plot(ax(4),real(gstub),imag(gstub),'bo')

Zbs=(1/Z0*(1-gstub)/(1+gstub)) ^-1 % using Z Smith chart values as if reversed Y Smith chart
Smith_plotBarc(ax(4),Zbs,Z0,[1 0 1]) % constant reactance arc plot line can also be called after defining Zbs

Zbs2=1j*imag(Zbs)

refl_Zstub=(Z0-Zbs2)/(Z0+Zbs2)
refl_Ystub=-refl_Zstub

plot(ax(4),real(refl_Ystub),imag(refl_Ystub),'ro')

Smith_plotRefLine2PhaseCircle(ax(4),Zbs2,Z0,[.2 .2 .8])

[​IMG]

da=1/100;a_stub=[angle(refl_Ystub): -da : -pi];arc_stub2=da;

for k=1:1:numel(a_stub)
gamma_stub=cos(a_stub)+1j*sin(a_stub);
arc_stub2=arc_stub2+da;
plot(ax(4),real(gamma_stub),imag(gamma_stub),'bo','LineWidth',1.5);
end
arc_stub2=arc_stub2-da;


[​IMG]


directly from the intersection points

Dstub2_lambda=abs(-pi-angle(gstub))*.5/pi
Dstub2_angle_rad=abs(-pi-angle(gstub))/2
Dstub2_angle_deg=abs(-pi-angle(gstub))*90/pi


Dstub2_lambda=abs(-pi-angle(gstub))*.25/pi


electric length of OC stub

Dstub2_angle_rad=abs(-pi-angle(gstub))/2

Dstub2_angle_deg=abs(-pi-angle(gstub))*90/pi


from the arc on Smith chart

arc_stub2_lambda=.25/pi*arc_stub2

same as

Dstub2_lambda=arc_stub2/(4*pi)

Dstub2_angle_deg=arc_stub2/2*360/(2*pi)




Without Smith chart

[POZAR] solves this single open shunt stub match directly with the following equations

[​IMG]

The same equations are also extensively used by Ali Behagi [BEH] in his book 'RF and Microwave Circuit Design'

https://www.amazon.co.uk/RF-Microwave-Circuit-Design-Approach/dp/0996446613

[BEH] writes his book entirely using Keysight's ADS

https://www.keysight.com/en/pc-1297113/advanced-design-system-ads?cc=GB&lc=eng

These equations, in MATLAB:

RL=real(ZL);XL=imag(ZL);Y0=1/Z0;

% when RL~=Z0 (~= same as != or <> not equal to)
t1=(XL+((RL*((Z0-RL)^2+XL^2))/Z0)^.5)/(RL-Z0)
t2=(XL-((RL*((Z0-RL)^2+XL^2))/Z0)^.5)/(RL-Z0)


% when RL==Z0
D1_TL=1/(2*pi)*atan(t1);if atan(t1)<0 D1_TL=D1_TL+.5; end
D2_TL=1/(2*pi)*atan(t2);if atan(t2)<0 D2_TL=D2_TL+.5; end


B1=(RL^2*t1-(Z0-XL*t1)*(XL+Z0*t1))/(Z0*(RL^2+(XL+Z0*t1)^2))
B2=(RL^2*t2-(Z0-XL*t2)*(XL+Z0*t2))/(Z0*(RL^2+(XL+Z0*t2)^2))


Dstub1=1/(2*pi)*atan(B1/Y0); if atan(B1/Y0)<0 Dstub1=Dstub1+.5; end
Dstub2=1/(2*pi)*atan(B2/Y0); if atan(B2/Y0)<0 Dstub2=Dstub2+.5; end


Dstub1oc=Dstub1
Dstub2oc=Dstub2


t1
= 7.071261637588793
t2
= -0.671261637588793

D1_TL
= 0.227640974365225
D2_TL
= 0.405911259087935

B1
= 0.012904205458629
B2
= -0.012904205458629

Dstub1oc
= 0.122397174557474
Dstub2oc
= 0.372397174557474




Putting Smith chart and equation obtained transmission line and stub lengths together:

D_TL=[D1_TL_lambda D2_TL_lambda]
Dstub=[Dstub1_lambda Dstub2_lambda]



from the equations

D_TL_eq=[D1_TL D2_TL]
Dstub_eq=[Dstub1oc Dstub2oc]



either combine

D_TL(1)
Dstub(1)


or

D_TL(2)
Dstub(2)



So, all obtained TL and stub length in one matrix

D=[D_TL D_TL_eq;Dstub([2 1]) Dstub_eq([2 1])]

D =
Columns 1 through 3
0.405924682355882 0.227671146092940 0.227640974365225
0.162338041953733 0.339238761200356 0.377602825442526
Column 4
0.405911259087935
0.122397174557474




Frequency response

Let be the following f0 and band:

c0=2.998e8;
f0=2e9;
df=1e6;f1=1e9;f2=3e9;f=[f1:df:f2];


% Then the physical lengths of all transmission lines and stubs are:

L=D*c0/f0

L =
Columns 1 through 3
0.060848109885147 0.034127904799332 0.034123382057347
0.024334472488865 0.050851890303933 0.056602663533835
Column 4
0.060846097737281
0.018347336466165


frequency sweep

Y0=1/Z0;
GL=real(YL);BL=imag(YL);

s11=zeros(size(D,2),numel(f)); % s11_mod=zeros(size(D,2),numel(f));

ZinTL=zeros(size(D,2),numel(f));
Zin_stb_oc=zeros(size(D,2),numel(f));
Zin=zeros(size(D,2),numel(f));


for k=1:1:size(L,2)

ZinTL(k,: )=Z0*(ZL+1j*Z0*tan(2*pi*f/c0*L(1,k)))./(Z0+1j*ZL*tan(2*pi*f/c0*L(1,k))); % series transmission line input impedance
end

for k=1:1:size(D,2)

Zin_stb_oc(k,: )=Z0./(1j*tan(2*pi*L(2,k)*f/c0)); % open circuit shunt stub input impedance
end

Zin=1./(ZinTL.^-1+Zin_stb_oc.^-1);

s11=(Zin-Z0)./(Zin+Z0);
s11_mod=abs(s11);

for k=1:1:size(s11_mod,1)
hf(10)=figure(10);plot(f,s11_mod(k,: ));hold all;
end
grid on
title('TL + OC shunt stub |s11| - f sweep');xlabel('f [Hz]')
legend('arc1','arc2','eq1','eq2','Location','northwest')



[​IMG]

[​IMG]

Sweep relative frequency f/f0:

frel=linspace(.5,1.5,numel(f));

for k=1:1:size(L,2)

ZinTL(k,: )=Z0*(ZL+1j*Z0*tan(2*pi*frel*f0/c0*L(1,k)))./(Z0+1j*ZL*tan(2*pi*frel*f0/c0*L(1,k))); % series transmission line input impedance
end

for k=1:1:size(D,2)
Zin_stb_oc(k,: )=Z0./(1j*tan(2*pi*L(2,k)*frel*f0/c0));
% open circuit shunt stub input impedance
end

Zin=1./(ZinTL.^-1+Zin_stb_oc.^-1);

s11=(Zin-Z0)./(Zin+Z0);
s11_mod=abs(s11);

for k=1:1:size(s11_mod,1)
hf(11)=figure(11);plot(frel,s11_mod(k,: ));hold all;
end
grid on
title('TL + OC shunt stub |s11| - f relative sweep');xlabel('frel=f/f0')
legend('arc1','arc2','eq1','eq2','Location','northwest')


Resulting same plot.

Sweep transmission line and stub lengths

Drel=linspace(.5,1.5,numel(f));

for k=1:1:size(L,2)

ZinTL(k,: )=Z0*(ZL+1j*Z0*tan(2*pi*Drel*D(1,k)))./(Z0+1j*ZL*tan(2*pi*Drel*D(1,k)));
% series transmission line input impedance
end

for k=1:1:size(D,2)

Zin_stb_oc(k,: )=Z0./(1j*tan(2*pi*Drel*D(2,k))); % open circuit shunt stub input impedance
end

Zin=1./(ZinTL.^-1+Zin_stb_oc.^-1);

s11=(Zin-Z0)./(Zin+Z0);
s11_mod=abs(s11);

for k=1:1:size(s11_mod,1)
hf(12)=figure(12);plot(Drel,s11_mod(k,: ));hold all;
end
grid on
title('TL + OC shunt stub |s11| - stub length sweep');
xlabel('Drel=[D/a a*D]')
legend('arc1','arc2','eq1','eq2','Location','northwest')


Resulting again same plot.

Complete overlap of frequency responses, the calculated lengths with Smith Chart arcs and directly with the customized equations return same
transmission line, OC shunt stub lengths.


Comment error when stubs slightly short because of Smith Chart Zin reading error:

in attached script pozar_05_exercise_03.m 2nd part erroneously reads stubs Zin following straight lines, with the following frequency response


[​IMG]

Observation: Despite both stubs being a little bit too short, one pushes the deteriorated frequency notch
to a slightly higher frequency, while the other, still being a bit shorter than it should be, it shifts the
deteriorated frequency notch to a slightly lower frequency. So, for fine tuning, it's not always 'shorter'
for higher frequencies or 'longer' for lower frequencies.



John BG
jgb2012@sky.com


The superbly robust support function included in the attached .zip was written by Mr Douglas Schwarz, that can be downloaded from https://www.mathworks.com/matlabcentral/fileexchange/11837-fast-and-robust-curve-intersections
You need to be logged in to comment