Professional Documents
Culture Documents
EXAMPLE 2.3
Click any to open the MATLAB script solving this exercise. Run script to read question and calculate solution.
On 1st run, the exercise is solved and results are stored in .mat file. Parameters can be modified to solve exercise
variations. MATLAB student licences are free for students in university or college, toolboxes upgrades are cheap
and there is a licence type that does not even require to be registered in any learning institution.
To download and install MATLAB as well as review help on specific commands click any MATLAB icon:
Download .mlx
Contents
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 1 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
pozar_02_example_03.m
c0=physconst('Lightspeed'); % [m/s]
Z0=50; % [ohm] TL
ZL=100+1j*50; % [ohm] load
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 2 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
c=[1 0 0];
% load reflection coefficient
[rLza rLzm]=Smith_pinZ(ax,ZL,Z0,[1 0 0],0)
[rLzx,rLzy]=pol2cart(rLza,rLzm);0
text(ax,rLzx+.2,rLzy+.05,'zL',...
'Color',[.7 0 0],...
'FontSize',15,...
'HorizontalAlignment','right',...
'VerticalAlignment','middle');
text(ax,rLyx-.05,rLyy+.05,'yL',...
'Color',[.7 0 0],...
'FontSize',15,...
'HorizontalAlignment','right',...
'VerticalAlignment','middle');
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 3 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
[r2x,r2y]=Smith_swrArc(ax,ZL,Z0,a,RL,c);
gammazin=r2x(end)+1j*r2y(end);
Zin_sc=Z0*(1+gammazin)/(1-gammazin)
Yin_check=1/Zin_sc
gammazin =
0.0666 - 0.4422i
Zin_sc =
37.4972 -41.4553i
Yin_check =
0.0120 + 0.0133i
[riyx,riyy]=Smith_swrArc(ax,YL,1/Z0,a,RL,[0 0 1]);
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 4 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
gammayin=riyx(end)+1j*riyy(end);
% this is Yin
Yin_sc=1/Z0*(1+gammayin)/(1-gammayin) Yin_sc =
0.0120 + 0.0133i
% and this Zin
Zin_check=1/(1/Z0*(1+gammayin)/(1-gammayin)) Zin_check =
37.4956 -41.4539i
Zin=Z0*(ZL+1j*Z0*tan(2*pi*D))/(Z0+1j*ZL*tan(2*pi*D)) Zin =
37.4956 -41.4539i
Yin=1/Zin Yin =
0.0120 + 0.0133i
All values calculated directly match to those graphically obtained on Smith Chart.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 5 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
6.- Test with the Quite Universal Circuit Simulator Produces Errors
Details how to install and available workbook link in [1]. Using version 0.0.19. 1st contact:
example_02_03_02.sch
Note that the above S[1,1] arc in red on Smith Chart shows
the correct load ZL at 1GHz, but the arc is not an SWR circle.
It's a frequency sweep.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 6 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
example_02_03_03.sch
When a component
value sweep is
attempted on a single
frequency, at least as
follows, the simulation
produces no errors, but
no results are plotted on
the Smith Chart either. I
tried both single port, 2
ports, and with and AC
simulation block.
example_02_03_04.sch
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 7 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
example_02_03_08.sch
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 8 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
example_02_03_05.sch
example_02_03_09.sch
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 9 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
There is another simulator named QUCSSTUDIO [3] that produces correct result on 1st round. List of QUCSTUDIO available
examples in [4].
I use the same icon for QUCS and QUCSTUDIO circuits but QUCSTUDIO does not open QUCS circuits and I may know why.
ucs_02_01.sch
S Parameter sweep
between .5GHz and
1.5GHz with 101 points.
QUCSTUDIO markers
nicely glide on traces.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 10 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 11 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
previous_02_example_03.m
Following the previous solution, without Smith Chart support functions. Same correct results obtained.
if imag(ZL)<0
sign1='-'
else
sign1='+'
end
hold all;plot(real(gamma),imag(gamma),'ro','LineWidth',1.5)
str1=['ZL =' num2str(real(ZL)) sign1 'j' num2str(abs(imag(ZL))) ' \rightarrow'];
text(real(gamma),imag(gamma)+.01,str1,'Color','blue','FontSize',20,'HorizontalAlignment','right','VerticalAlignment','middle')
r=abs(gamma)
SWR=(1+r)/(1-r)
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 12 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
RL=-20*log10(r)
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 13 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
7.1.- Smith_pinZ
Smith_pinZ(ax,Z,Z0,c,s)
function [gamma_Z_angle,gamma_Z_mod]=Smith_pinZ(ax,Z,Z0,c,s)
% SMITH_PINZ : Support function for Smith Chart operations.
%
% SMITH_PINZ plots on Z Smith Chart the reflection coefficient of input impedance Z.
%
% Before calling SMITH_PINZ open blank Smith Chart with for instance the
% following commands:
% fh=figure
% ax=gca
% sm1=smithplot
%
% INPUT FIELDS:
%
% ax : graphics handle of figure containing Smith Chart generated with smithplot.
% always required to avoid sending the marker plotting to different figure.
%
% Z : [ohm] single value, input impedance R+1j*X, do not normalise values.
%
% Z0 : [ohm] single value, Transmission Line characteristic impedance.
%
% c : [R G B] 0 to 1 range colour definition for Marker edge plotted showing Z position.
% 0:white 1:black
%
% s : [0 1] switch to print ZL=R+jX : s=1 text showing 'ZL=R+jX' values is added.
% s=0 output NO text showing ZL=R+jX data is added.
% any other value of s pops error message on command prompt and null
%
% OUTPUT FIELDS:
% gamma_Z_angle, gamma_Z_mod: reflection coefficient is complex and carteisan real(refl) + 1j*imag(refl) format
%
% angles sign, same angle for instance -60º can also show
% up as 300º, can be avoided when only using positive angles, for all angles.
%
% there have to be exactly 5 inputs and exactly 1 complex output
%
% Author: John Bofarull Guix
% contact: jgb2012@sky.com jgb2014@live.co.uk
%
gamma_Z=z2gamma(Z,Z0); % refl=(ZL-Z0)/(ZL+Z0)
gamma_Z_angle=angle(gamma_Z);
gamma_Z_mod=abs(gamma_Z);
if gamma_Z_angle>(2*pi)
gamma_Z_angle=gamma_Z_angle-2*pi;
end
% gamma_Z=pol2cart(gamma_Z_angle,gamma_Z_mod)
% gamma_Z=gamma_Z_mod*(cos(gamma_Z_angle)+1j*sin(gamma_Z_angle))
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 14 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
hp1=plot(ax,real(gamma_Z),imag(gamma_Z),'ro')
hp1.LineStyle='none'
hp1.LineWidth=.5;
hp1.Marker='o';
hp1.MarkerSize=6;
hp1.MarkerFaceColor='none';
hp1.MarkerEdgeColor=c;
switch s
if imag(Z)<0
sign1='-';
else
sign1='+';
end
hold all;
plot(ax,real(gamma_Z),imag(gamma_Z),'ro','LineWidth',1.5);
text(ax,real(gamma_Z),imag(gamma_Z)+.01,...
str1,'Color','blue',...
'FontSize',20,...
'HorizontalAlignment','right',...
'VerticalAlignment','middle');
case 0
% gamma already on SC . Put here more code in case
% some else to be done when NO explicit tag showing Z=R+1jX
otherwise
% s out of range
gamma_Z=0+1j*0;
end
end
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 15 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
7.2.- Smith_swrCircle
Smith_swrCircle(ax,Z,Z0,c)
function [x_data,y_data]=Smith_swrCircle(ax,Z,Z0,c)
% PLOT_SWRCIRCLE plots SWR full circle, lossless TL
%
% INPUTS
% ax: graphics handles of figure containing Smith Chart generated with smithplot.
% Z: [ohm] impedance, NOT normalised
% Z0: [ohm] Transmission Line characteristic impedance
% c: color format [r g b] each ranging [0 1] where 0:white 1:black
%
% OUTPUT
% SWR full circle points in cartesian format
input_checks;
gamma=z2gamma(Z,Z0);
r=abs(gamma);
alpha=0:2*pi/100:2*pi;
hold all;
sub_hp2=plot(ax,r*cos(alpha),r*sin(alpha),'-','LineWidth',.5,'Color',c);
x_data=sub_hp2.XData;
y_data=sub_hp2.YData;
function input_checks
% support function for SMITH_SWRCIRCLE
[szc1 szc2]=size(c);
if szc1>1 || szc2~=3
disp('\ncolour wrong amount elements\n');
return;
end
if max(c>1) || min(c<0)
disp('\ncolour component(s) out of range\n');
return;
end
if numel(Z0)>1
disp('\nZ0 cannot be vector\n');
return;
end
Z=Z(:);
[sz1 sz2]=size(Z);
cas=1;
if sz2>1
cas=2;
end
end
end
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 16 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
7.3.- Smith_swrArc
Smith_swrArc(ax,Z,Z0,a,RL,s)
function [x_data,y_data]=Smith_swrArc(ax,Z,Z0,a,RL,c)
% PLOT_SWRARC plots SWR arc a [rad] on Smith Chart CW or CCW according to RL and colour c
% TL assumed lossless
%
% INPUTS
% ax: graphics handles of figure containing Smith Chart generated with smithplot.
%
% Z: [ohm] impedance, NOT normalised, Start point of the Arc on Smith Chart
%
% Z0: [ohm] Transmission Line characteristic impedance
%
% a: [rad] arc angle
%
% RL : rotation direction [-1 1] -1: CW clockwise 1: CCW counter-clockwise
%
% c: color format [r g b] each ranging [0 1] where 0:white 1:black
%
% OUTPUT
% Arc points on Smith Chart in cartesian format starting on Z and CW/CWW according to RL
input_checks;
gamma_in=z2gamma(Z,Z0);
r=abs(gamma_in);
gamma_out=r*(cos(az)+1j*sin(az));
q=0;
if az<a0 & RL==-1 q=1; end;
if az<a0 & RL==1 q=2; end;
if az>a0 & RL==-1 q=3; end;
if az>a0 & RL==1 q=4; end;
switch q
case 1 % az<a0 & CW
alpha=[a0:-a/N:az];
case 3 % az>a0 % CW
alpha=[a0:-a/N:0 2*pi:-a/N:az];
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 17 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
alpha=[a0:a/N:az];
otherwise
disp('\nq within [1:4] only\n')
end
hold all;
sub_hp2=plot(ax,r*cos(alpha),r*sin(alpha),'-','LineWidth',2,'Color',c);
x_data=sub_hp2.XData;
y_data=sub_hp2.YData;
function input_checks
% support function for SMITH_SWRARC
if nargin~=6
disp('\ntrial version: 6 and only 6 input fields required\n');
return;
end
if numel(Z)>1
disp('\nZ scalar values only\n')
end
if numel(Z0)>1
disp('\nZ0 scalar only\n');
return;
end
if a==0 || mod(2*pi,a)==0
disp('\nChoose arc>0\n');
return;
end
if ~(RL==[-1 1])
disp('\nRL has to be either -1:CW or 1:CCW\n');
end
[szc1 szc2]=size(c);
if szc1>1 || szc2~=3
disp('\ncolour [R G B] wrong amount elements\n');
return;
end
if max(c>1) || min(c<0)
disp('\ncolour component(s) out of range\n');
return;
end
end
end
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 18 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
If you need help on using QUCs, please join the help mailing list : qucs-help on SourceForge
(please attach the schematic you are having problems with)
Some habits are not that easy to change: It would sell faster rebranding to just UCS : Universal Circuit Simulator.
http://qucsstudio.de/
author :Michael Margraf
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 19 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
system simulation optical telecommunication systems, eye diagrams, bit error rate (BER)
binary component library contains the following models: Curtice, Statz, TOM1…3, EKV, HICUM L0/L2, stripline and
more (many thanks to Mike Brinson for contributing most of the models)
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 20 / 21
POZAR chapter 02 Transmission Line Basics: Example 03 16/04/2023 11:45:45.
______________________________________________________________________________________________________________________________
John Bofarull Guix jgb2012@sky.com mailto:jgb2014@live.co.ukailto: attached: all 21 / 21