Plot a Smith Chart in Matlab
MatrixLab Examples
For a variant of the code, applications and more examples, see: http://matrixlab-examples.com/smith-chart.html
In this video I’m going to show you how to plot a Smith chart in Matlab. You don’t need special functions or toolboxes.
A Smith Chart is just a group of circles and portions of circles (arcs).
We need to develop a function that plots a circle and call it several times to plot horizontally aligned circles with different centers and radii, and call that function again to plot vertically aligned portions of circles.
First, we develop a function to draw a circle using some input parameters.
% This function plots a circle or just a portion % It needs 5 input parameters: % center = (xc, yc) % r = radius % starting point (angle) = a1 % final point (angle) = a2
% It does not have any output but the plot
function plot_circle(xc, yc, r, a1, a2) t = linspace(a1, a2, 360); x = xc + r * cos(t); y = yc + r * sin(t); plot(x, y);
Now, we call that function from a driver that predefines centers and radii… We change the horizontal values but keep the vertical values at 0, meaning that these circles are horizontally aligned.
function plot_smith_chart
% select the centers of the horizontal circles xc = [0 .25 .5 .75]; yc = 0;
% iterate thru the different centers and radii for i = 1 : length(xc) plot_circle(xc(i), yc, 1-xc(i), 0, 2*pi) hold on end
If you run that portion of the code, you get this figure.
We need to retouch the image by adjusting the aspect ratio, removing the values along the axes and adding a title.
% adjust the aspect ratio and retouch a bit axis equal; title(' Smith Chart ') set(gca, 'xticklabel', {[]}); set(gca, 'yticklabel', {[]});
If you add that portion to the code, you get now this improvement.
Now, we plot the vertical arcs.
% iterate thru the vertical circles with % appropriate angles and radii xc = 1; yc = [.5 1 2 4]; % choose starting points (trial and error?) a1 = [2.5 pi 3.79 4.22];
for i = 1 : length(yc) % upper arcs plot_circle(xc, yc(i), yc(i), a1(i), 3/2pi) % lower arcs plot_circle(xc, -yc(i), yc(i), pi/2, 2pi - a1(i)) end
Finally, we run the main driver from another function or from the main window… and we get our Smith chart in Matlab.
% clear screen, memory and figure windows clc, clear, close all
% plot the chart plot_smith_chart
Done!
5736666 Bytes