# Smith Chart MATLAB Code on Mathworks website - Explanation

20 views (last 30 days)
Ammar Babikir on 13 Aug 2017
Edited: Janakinadh on 9 Jun 2021
Hello everyone,
I am trying to plot the Smith chart for a given data set. I have a set of data ranging from 2GHZ - 3GHZ with an (R) + j(X) value for each individual frequency point. I have the CSV file with all these data points. I attached a sample of the data that I have: Frequency, R, X.
I am new to plotting smith charts on MATLAB. I was wondering if anyone has had any experience plotting Smith charts on MATLAB and would be able to explain the Example code from the Mathworks website: smithchart
I'm trying to understand the "Plotting Impedance" code that's already on the Mathworks website:
z = 0.1*50 + 1j*(0:0.1:50);
gamma = z2gamma(z);
figure
smithchart(gamma)
I do have a base knowledge in the theory of Transmission Lines, Reflection Coefficient, Voltage Standing Wave Ratio (VSWR) Input/output/load impedance etc. So, in this case, what is "z"? Is it ZLoad, Z output, or Zinput? Also, what is the 0:0.1:50 range representing? Is that representing the range of Zo from 0 to 50 ohms with an increment of 0.1? Also what exactly does z2gamma mean in the code?
Also, in the "Plotting Reflection" code that's also given on the Mathworks website:
S = sparameters('passive.s2p');
s11 = rfparam(S,1,1);
figure
smithchart(s11)
I am only interested in plotting S11 parameters with my data. I understand that smithchart(s11) is basically the function to plot the s11 parameters. But, what does 'passive.s2p' mean? What do sparameters and rfparam represent?
dpb on 14 Aug 2017
|sparameters| is an (overloaded) function in the RF and Antenna Toolboxes --
see the doc for it for the details on what it returns. As it is, it appears that's the one for the RF Toolbox as z2gamma is in RF TB and doc for it say "z2gamma(z) converts the impedance z to the reflection coefficient gamma using a reference impedance of 50 ohms".
Just dig through the doc looking for functions of the name and you can work through what it is they did..."I know nothink!" about the subject field so can't say much more but they're functions in RF TB so if you know that field should become clear I'd think...
For an example just to make a plot I don't know that I'd try to read too much into what z actually is -- it likely is just a complex variable vector chosen to make a pretty plot, nothing more.

Edited: Janakinadh on 9 Jun 2021
Hello,
Please use smithplot for plotting data on Smith Chart.
For the posted question, the data can be plotted using:
freq = [2.19e9; 2.20e9]; % Frequencies
Zmeasured = [5.05e-1+1i*8.26e1; ...
5.05e-1+1i*8.23e1]; % Impedance data
Zref = 75; % Reference impedance
% Convert impedance to reflection coefficient
S11 = z2gamma(Zmeasured,Zref);
% Plot data on Smith
smithplot(freq,S11,'Marker','*')
z2gamma converts any impedance data to reflection coefficient for it to be plotted onto the Smith Chart. In the below script/example, we are trying to plot a part of the resistance circle R = 0.1 by varying the Xj.
z = 0.1*50 + 1j*(0:0.1:50);
gamma = z2gamma(z);
smithplot(gamma)
passive.s2p is measured S-parameters data. This Touchstone file comes with the software and can be viewed.
edit passive.s2p
sparameters is used to read the S-parameters from the file, and rfparam is used to extract desired S-parameters, S11 for example.
I hope this helps.