Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matlab coding for RF microwave assignment. Below is the requirement for the task

ID: 2083655 • Letter: M

Question

Matlab coding for RF microwave assignment.

Below is the requirement for the task:

I need to design a vector network analyzer to measure the reflect coefficient for unknown device.

DUT: assume ZL = 50 + j50 ; Z0 = 50 -------plot the reflection coefficient circle on smith chart name as circle1;

Additional known impedance L1=50j connect with DUT : ZL1= 50 +100 j -----plot the reflection coefficient circle on smith chart name as circle2;

Use another known impedance L2=100j connect with DUT: ZL2=50 + 150j ------plot the reflection coefficient circle on smith chart name as circle3;

Because ZL1 and ZL2 compare with DUT, only imaginary part changed and real part remain the same, so ideally to shift the circle2 down by 'j ' and circle3 down by '2j', then the new shifted circle2' and circle3' are having one intersection point with circle1. And the from the intersection point's coordinate with real part and imaginary part, I can compute the magnitude and phase of the reflection coefficient for the DUT.

I need to use matlab to prove the 3 circles are having one intersection point.

Explanation / Answer

#matlab code for smith chart for reflection at one intersection point:1st method

function draw_smith_chart

% Draw outer circle
t = linspace(0, 2*pi, 100);
x = cos(t);
y = sin(t);
plot(x, y, 'linewidth', 3); axis equal;

% Place title and remove ticks from axes
title(' Smith Chart ')
set(gca,'xticklabel',{[]});
set(gca,'yticklabel',{[]});
hold on

% Draw circles along horizontal axis
k = [.25 .5 .75];
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 = [2.5 pi 3.79 4.22];
k = [.5 1 2 4];
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


%calculate reflection losse and standing wave ratio and losses

function [m, thd, SWR, rloss] = smith_ch_calc(Z0, Zl)

% Draw appropriate chart
draw_smith_chart

% Normalize given impedance
zl = Zl/Z0;

% Calculate reflection, magnitude and angle
g = (zl - 1)/(zl + 1);
m = abs(g);
th = angle(g);

% Plot appropriate point
polar(th, m, 'r*')

% Change radians to degrees
thd = th * 180/pi;

% Calculate VSWR and return loss.
% We can add epsilon to magnitude, to avoid div by 0 or log(0)
SWR = (1 + m)/(1 - m + eps);
rloss = -20 * log10(m + eps);

%now try our functions
clear, clc, close all, format compact
[m1, d1, VSWR1, Rloss1] = smith_ch_calc(50, 50)
[m2, d2, VSWR2, Rloss2] = smith_ch_calc(50, 50 + 100j)
[m3, d3, VSWR3, Rloss3] = smith_ch_calc(50, 50 +j*150)

-------------------------------------------------------------------------------------------------------------

second method
% programme for transmission line parameter using smith chart
clc;
clear;
close all;
a= input('Enter the real value of load Impedance ZL, a= ');
b=input('Enter the Immaginary value of load impedance ZL, b= ');
ZL= a+1i*b;
disp(['ZL= ',num2str(ZL),'ohm']);
a1= input('Enter the real value of characteristic Impedance Z0, a1= ');
b1=input('Enter the Immaginary value of characteristic impedance Z0, b1= ');
Z0= a1+1i*b1;
disp(['Z0= ',num2str(Z0),'ohm']);
disp('Enter the R- To Determine the Voltage reflection coefficient');
disp('Enter the V- To Determine the VSWR');
disp('Enter the Z- To Determine the impedance Zx from load');
c = input('Enter your choice','s');
switch c case 'R' rc=(ZL-Z0)/(ZL+Z0);
disp(['The Voltage reflection coefficient is' ,num2str(rc)]);
case 'V' rc=(ZL-Z0)/(ZL+Z0);
x=real(rc);
y=imag(rc);
q=sqrt(x^2+y^2);
VSWR=(1+q)/(1-q);
disp(['The VSWR is' ,num2str(VSWR)]);
case 'Z' zx= Z0*((ZL+1i*Z0*tan((2*pi)*0.35))/(Z0+1i*ZL*tan((2*pi)*0.35)));
disp(['The Zx from load ZL is ' ,num2str(zx),'ohm']); otherwise error('invalid choice'); end