How to plot Smith chart?

205 Ansichten (letzte 30 Tage)
John Taker
John Taker am 1 Nov. 2016
Hello. I need to plot Smith chart, having frequency, VSWR, reflection coefficient and phase. I'm fairly new to matlab environment and not sure how to achieve it. Tried already this from mathworks website, it didn't even seemed remotely okay. As it says, I've tried to plot reflection coefficient as gamma. Screen with my data and result I've got:
  2 Kommentare
Muhammad Syafiq Bin Salahudin
Hi,
Is there any way to compile these codes into MATLAB App GUI?
Janakinadh
Janakinadh am 8 Jun. 2021
MATLAB's smithplot is compatible with uipanel. An uipanel is a common container in MATLAB Apps.
Usage:
smithplot('Parent', uipanel)
You can use appdesigner to easily build App GUI in MATLAB. That App can have a smithplot live in a panel.
Also see: Matching Network App where a smithplot is plotted in an uipanel to plot S-parameters and impedance transformation.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

John BG
John BG am 2 Dez. 2016
Bearbeitet: Stephen23 am 26 Nov. 2017
Hi Mr Taker
There are many ways to plot data on MATLAB Smith charts
1.- basic plot of single impedance
clc;clear all;format long;
Z0=100;sm1=smithchart;
ZL1=150-1j*200;f0=3e9; % Hz
gamma_L=(ZL1-Z0)/(ZL1+Z0);
% show ZL1 on Smith chart adding text showing values
if imag(ZL1)<0
sign1='-';
else
sign1='+';
end
hold all;plot(real(gamma_L),imag(gamma_L),'ro','LineWidth',1.5);
str1=['ZL =' num2str(real(ZL1)) sign1 'j' num2str(abs(imag(ZL1))) ' \rightarrow'];
text(real(gamma_L),imag(gamma_L)+.01,str1,'Color','blue','FontSize',20,'HorizontalAlignment','right','VerticalAlignment','middle');
2.- solving a basic single stub ZLoad match:
the functions I use are as follows:
function [x_data,y_data]=Smith_plotGammaCircle(ax,Z,Z0)
% plot SWR circle, lossless TL
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',[1 .2 0])
x_data=sub_hp2.XData
y_data=sub_hp2.YData
end
function Smith_plotRefLine2PhaseCircle(ax,Z,Z0)
% plot reference line from origin through ZL to phase reference circle
gamma_L=z2gamma(Z,Z0);
a=atan(imag(gamma_L)/real(gamma_L));
plot(ax,[0 cos(a)],[0 sin(a)],'Color',[0 0.7 0],'LineWidth',1)
end
function a=Smith_plotRefLine2PhaseCircle(ax,Z,Z0)
% plot reference line from origin oppsite to ZL to phase reference circle
% it plots ref line through YL
gamma_L=(Z-Z0)/(Z+Z0)
a=angle(gamma_L)
plot(ax,[0 -real(exp(1j*a))],[0 -imag(exp(1j*a))],'Color',[0 0.7 0],'LineWidth',1)
end
function Smith_plotZ(ax,Z,Z0)
% add text showing ZL R+jX data, Smith Chart generated externally
gamma=z2gamma(Z,Z0);
plot(ax,real(gamma),imag(gamma),'ro','LineWidth',1.5)
if imag(Z)<0
sign1='-';
else
sign1='+';
end
hold all;plot(ax,real(gamma),imag(gamma),'ro','LineWidth',1.5);
str1=['ZL =' num2str(real(Z)) sign1 'j' num2str(abs(imag(Z))) ' \rightarrow'];
text(ax,real(gamma),imag(gamma)+.01,str1,'Color','blue','FontSize',20,'HorizontalAlignment','right','VerticalAlignment','middle');
end
3.- adding reactance/resistance circle sections and a legend
Z0=75; ZL=90+1j*60;
sm1=smithchart; ax=gca; hold all;
sm1.Values = [.1 .2 .3 .5 1 1.5 2 3.5 5;1 1.5 2 3.5 5 5 5 15 30]
sm1.SubColor=[.2 .2 .2]
gamma_ZL=(ZL-Z0)/(ZL+Z0); gamma_YL=-gamma_ZL
plot(ax,real(gamma_ZL),imag(gamma_ZL),'ro','LineWidth',1.5)
plot(ax,real(gamma_YL),imag(gamma_YL),'bo','LineWidth',1.5)
hl1=legend(ax,{'ZL','YL'}, 'Location','bestoutside');title(hl1,'points')
Smith_plotRefLine2PhaseCircle(ax,ZL,Z0)
[x_circ1,y_circ1]=Smith_plotGammaCircle(ax,ZL,Z0);
[x_circ2,y_circ2]=Smith_plotRcircle(ax,Z0,Z0);
[x_target,y_target]=kreuzungen(x_circ1,y_circ1,x_circ2,y_circ2)
plot(ax,x_target(1),y_target(1),'ro','LineWidth',1.5)
plot(ax,x_target(2),y_target(2),'ro','LineWidth',1.5)
The function kreuzungen appended to these lines was developed by Douglas M. Schwarz dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu function available in this forum too.
4.- there are different custom toolboxes available in MATLAB file exchange. One that allows to set Z0 as input to a Smith chart related function of the tool set is
by Neil Tucker
The drawback of Tucker's is that his core function is named exactly as MATLAB RF toolbox smith, the problem being that while MATLAB’s smith does not take in Z0, MATLAB's smith only plots normalised impedances/admittances. When attempting to call Tucker's smith MATLAB returns zero, I got it working by renaming Tucker's smith function.
5.- Although encouraging Smith chart functions development with MATLAB, I am now learning KEYSIGHT ADS, and it's the right tool to solve RF circuits with Smith Chart plots.
.
So, Taker if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG
EDIT: deleted Douglas Schwarz's copyright code.
  4 Kommentare
John BG
John BG am 10 Aug. 2017
Hi Ammar Babikir
there is an early (2003) collection of functions available in the MATLAB file exchange that has a function called smith.
When one tries to run that smith function, that has many input fields, the same error message shows up.
There's this other group of Smith chart related functions
that has a function called exactly smithchart, and again, it's going cause anything but conflict.
So, make sure that whatever other Smith chart tools you may have downloaded, for earlier MATLAB versions, for evaluation, make sure that the files are not in the MATLAB working folder.
Regards
John BG
Harrison Norris
Harrison Norris am 13 Nov. 2020
Hey, looking through your code. How does your Smith_plotRcircle function work and I can find no mention of any kind of kreuzungen function other than on this page. I know its been awhile since posting, just looking for Info.
Thanks,
Harrison Norris

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

MathWorks Support Team
MathWorks Support Team am 7 Mär. 2022
MATLAB's smithplot is compatible with uipanel. An uipanel is a common container in MATLAB Apps.
Usage:
smithplot('Parent', uipanel)
You can use appdesigner to easily build App GUI in MATLAB. That App can have a smithplot live in a panel.
Also see: Matching Network App where a smithplot is plotted in an uipanel to plot S-parameters and impedance transformation.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by