问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

求Smith圆图程序(用MATLAB或VB或VC)

发布网友 发布时间:2022-05-12 16:58

我来回答

4个回答

热心网友 时间:2023-08-22 10:45

%Victor Aprea Cornell University 6/27/02
%
%Usage: plotsmithchart(Zl,Zo)
% where Zl is the Load Impedence (possibly complex)
% and Zo is the Characteristic Line Impedence
% Plots a smith chart, along with the reflection coefficient circle
% and the line of intersection with resistive component equal to 1.

% plotsmithchart
% Without any parameters draws a blank smith chart.
% Wavelengths toward the generator are labeled around the perimeter
%
%For example: plotsmithchart(25,50)
% Draws a smithchart, calculates and plots the reflection coefficient
% for a characteristic impedence of 50 ohms and a load impedence of 25 ohms,
% and draws the line of intersection with the R=1 circle.

function answer = plotSmithChart(Zl,Zo);
constant = linspace(0,10,5);
phaseAngle = linspace(0,2*pi,50);
unitGamma = exp(j*phaseAngle);
%plot the unit circle in the complex plane
hold on;
plot(real(unitGamma),imag(unitGamma),'r');
%set(gcf,'Position',[0 0 1280 990]);
axis square
zoom on
axis([-1.1 1.1 -1.1 1.1]);

MAX=2001;
bound2=0;
bound3=0;
min_bound1=0;
min_bound2=0;
max_bound2=0;
H=0;
word=0;

Gr = linspace(-1,1,MAX);
hold on;

interval = [[.01:.01:.2],[.22:.02:.5],[.55:.05:1],[1.1:.1:2],[2.2:.2:5],[6:10],[12:2:20],[30:10:50]];
interval2= [[.01:.01:.5],[.55:.05:1],[1.1:.1:2],[2.2:.2:5],[6:10],[12:2:20],[30:10:50]];

%plot real axis
plot(Gr, zeros(1,length(Gr)),'r');

%equations were derived using the symbolic toolbox as follows
%solve('R=(1-Gr^2-Gi^2)/((1-Gr)^2+Gi^2)','Gi')
%bound was derived as follows
%solve('1/(R+1)*(-(R+1)*(R-2*R*Gr+R.*Gr^2-1+Gr^2))^(1/2)=0','Gr')
for R = interval2,
min_bound1 = (R-1)/(R+1);

if(R<.2)
if(mod(R,.1)==0)
max_bound = (-1+2^2+R^2)/(2^2+R^2+2*R+1);
elseif(mod(R,.02)==0)
max_bound = (-1+.5^2+R^2)/(.5^2+R^2+2*R+1);
else
max_bound = (-1+.2^2+R^2)/(.2^2+R^2+2*R+1);
if(R==.05 | (R<.151 & R>.149))
min_bound2 = (-1+.5^2+R^2)/(.5^2+R^2+2*R+1);
max_bound2 = (-1+1^2+R^2)/(1^2+R^2+2*R+1);
end
end
elseif(R<1)
if(mod(R,.2)==0)
max_bound = (-1+5^2+R^2)/(5^2+R^2+2*R+1);
elseif(mod(R,.1)==0)
max_bound = (-1+2^2+R^2)/(2^2+R^2+2*R+1);
elseif(R==.25 | R==.35 | R==.45)
temp = (-1+.5^2+R^2)/(.5^2+R^2+2*R+1);
min_bound2 = max(min_bound1, temp);
max_bound = (-1+1^2+R^2)/(1^2+R^2+2*R+1);
elseif(R<.5)
max_bound = (-1+.5^2+R^2)/(.5^2+R^2+2*R+1);
else
max_bound = (-1+1^2+R^2)/(1^2+R^2+2*R+1);
end
elseif(R<5)
if(mod(R,2)==0)
max_bound = (-1+20^2+R^2)/(20^2+R^2+2*R+1);
elseif(mod(R,1)==0)
max_bound = (-1+10^2+R^2)/(10^2+R^2+2*R+1);
elseif(R>2)
max_bound = (-1+5^2+R^2)/(5^2+R^2+2*R+1);
else
if(mod(R,.2)==0)
max_bound = (-1+5^2+R^2)/(5^2+R^2+2*R+1);
else
max_bound = (-1+2^2+R^2)/(2^2+R^2+2*R+1);
end
end
elseif(R<10)
if(mod(R,2)==0)
max_bound = (-1+20^2+R^2)/(20^2+R^2+2*R+1);
else
max_bound = (-1+10^2+R^2)/(10^2+R^2+2*R+1);
end
else
if(R==10|R==20)
max_bound = (-1+50^2+R^2)/(50^2+R^2+2*R+1);
elseif(R==50)
max_bound = 1;
elseif(R<20)
max_bound = (-1+20^2+R^2)/(20^2+R^2+2*R+1);
else
max_bound = (-1+50^2+R^2)/(50^2+R^2+2*R+1);
end
end

index = ceil((min_bound1+1)*(MAX-1)/2+1);
actual_value = Gr(index);
if(actual_value<min_bound1)
index = index + 1;
end
MIN=index;

index = ceil((max_bound+1)*(MAX-1)/2+1);
actual_value = Gr(index);
if(actual_value>max_bound)
index = index - 1;
end

MIN2 = ceil((min_bound2+1)*(MAX-1)/2+1);
actual_value = Gr(MIN2);
if(actual_value<min_bound2 )
MIN2 = MIN2 + 1;
end

MAX2 = ceil((max_bound2+1)*(MAX-1)/2+1);
actual_value = Gr(MAX2);
if(actual_value<max_bound2 )
MAX2 = MAX2 + 1;
end

r_L_a=1/(R+1)*(-(R+1)*(R-2*R.*Gr(MIN:index)+R.*Gr(MIN:index).^2-1+Gr(MIN:index).^2)).^(1/2);
r_L_b=-1/(R+1)*(-(R+1)*(R-2*R.*Gr(MIN:index)+R.*Gr(MIN:index).^2-1+Gr(MIN:index).^2)).^(1/2);
r_L_b(1)=0;
r_L_a(1)=0;

r_L_a2=1/(R+1)*(-(R+1)*(R-2*R.*Gr(MIN2:MAX2)+R.*Gr(MIN2:MAX2).^2-1+Gr(MIN2:MAX2).^2)).^(1/2);
r_L_b2=-1/(R+1)*(-(R+1)*(R-2*R.*Gr(MIN2:MAX2)+R.*Gr(MIN2:MAX2).^2-1+Gr(MIN2:MAX2).^2)).^(1/2);

r_L_a3=1/(R+1)*(-(R+1)*(R-2*R.*Gr(MIN2:index)+R.*Gr(MIN2:index).^2-1+Gr(MIN2:index).^2)).^(1/2);
r_L_b3=-1/(R+1)*(-(R+1)*(R-2*R.*Gr(MIN2:index)+R.*Gr(MIN2:index).^2-1+Gr(MIN2:index).^2)).^(1/2);

%fix resolution issues in .2-.5 range

if(~(R>.2 & R<.5 & ~(mod(R,.02)==0)))
if(R==1)
color = 'r';
else
color ='b';
end
plot(Gr(MIN:index),r_L_a(1:index-MIN+1),color,Gr(MIN:index), r_L_b(1:index-MIN+1),color);
if(R<=1)
if(mod(R,1)==0)
word = [num2str(R) '.0'];
else
word = num2str(R);
end

if(mod(R,.1)==0)
set(text(Gr(MIN),0,word),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');
end
elseif(R<=2)
if(mod(R,.2)==0)
if(mod(R,1)==0)
word = [num2str(R) '.0'];
else
word = num2str(R);
end
set(text(Gr(MIN),0,word),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');
end
elseif(R<=5)
if(mod(R,1)==0)
set(text(Gr(MIN),0,[num2str(R) '.0']),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');
end
else
if(mod(R,10)==0)
set(text(Gr(MIN),0,num2str(R)),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');
end
end
elseif(R==.25 | R==.35 | R==.45)
plot(Gr(MIN2:index),r_L_a3,'b');
plot(Gr(MIN2:index),r_L_b3,'b');
end

if(R==.05 | (R>.149 & R<.151))
plot(Gr(MIN2:MAX2),r_L_a2(length(Gr(MIN2:MAX2))-length(r_L_a2)+1:length(r_L_a2)),'b');
plot(Gr(MIN2:MAX2),r_L_b2(length(Gr(MIN2:MAX2))-length(r_L_b2)+1:length(r_L_b2)),'b');
end

end

%equations were derived using the symbolic toolbox as follows
%solve('2*Gi/((1-Gr)^2+Gi^2)=x','Gi')
%bound was derived as follows
%solve('1-X^2+2*X^2*Gr-X^2*Gr^2=0','Gr')
%solve('1/2/X*(2+2*(1-X^2+2*X^2*Gr-X^2*Gr^2)^(1/2))=(1-Gr^2)^(1/2)','Gr')
for X = interval,
inter_bound = (-1+X^2)/(X^2+1); %intersection with unit circle: all values must be less than this\
imag_bound = (-1+X)/X; %boundary of imagination: all values must be greater than this
angle_point = 0;
if(inter_bound ~= 0)
angle_point = sqrt(1-inter_bound^2)/inter_bound;
end

imag_bound_y = 1/2/X*(-2+2*(1-X^2+2*X^2.*inter_bound-X^2.*inter_bound.^2).^(1/2));

imag_rad = (imag_bound^2 + imag_bound_y^2)^(1/2);
condition = imag_rad < 1;
if(inter_bound > 1)
inter_bound = 1;
elseif(inter_bound < -1)
imag_bound=-1;
end

if(imag_bound > 1)
imag_bound = 1;
elseif(imag_bound < -1)
imag_bound=-1;
end

%used solve function to find intersection of appropriate circle with corresponding hyperbolics
%solve('-1/(R+1)*(-(R+1)*(R-2*R*Gr+R*Gr^2-1+Gr^2))^(1/2)=1/2/X*(-2+2*(1-X^2+2*X^2*Gr-X^2*Gr^2)^(1/2))','Gr')
%The following conditional tree creates the internal bounding between the two types of curves for variable resolution
if(X<.2)
if(mod(X,.1)==0)
max_bound = (-1+X^2+2^2)/(X^2+2^2+2*2+1);
elseif(mod(X,.02)==0)
max_bound = (-1+X^2+.5^2)/(X^2+.5^2+2*.5+1);
else
max_bound = (-1+X^2+.2^2)/(X^2+.2^2+2*.2+1);
end
elseif(X<1)
if(mod(X,.2)==0)
max_bound = (-1+X^2+5^2)/(X^2+5^2+2*5+1);
elseif(mod(X,.1)==0)
max_bound = (-1+X^2+2^2)/(X^2+2^2+2*2+1);
elseif(X<.5)
max_bound = (-1+X^2+.5^2)/(X^2+.5^2+2*.5+1);
else
max_bound = (-1+X^2+1^2)/(X^2+1^2+2*1+1);
end
elseif(X<5)
if(mod(X,2)==0)
max_bound = (-1+X^2+20^2)/(X^2+20^2+2*20+1);
elseif(mod(X,1)==0)
max_bound = (-1+X^2+10^2)/(X^2+10^2+2*10+1);
elseif(X>2)
max_bound = (-1+X^2+5^2)/(X^2+5^2+2*5+1);
else
if(mod(X,.2)==0)
max_bound = (-1+X^2+5^2)/(X^2+5^2+2*5+1);
else
max_bound = (-1+X^2+2^2)/(X^2+2^2+2*2+1);
end
end
elseif(X<10)
if(mod(X,2)==0)
max_bound = (-1+X^2+20^2)/(X^2+20^2+2*20+1);
else
max_bound = (-1+X^2+10^2)/(X^2+10^2+2*10+1);
end
else
if(X==10|X==20)
max_bound = (-1+X^2+50^2)/(X^2+50^2+2*50+1);
elseif(X==50)
max_bound = 1;
elseif(X<20)
max_bound = (-1+X^2+20^2)/(X^2+20^2+2*20+1);
else
max_bound = (-1+X^2+50^2)/(X^2+50^2+2*50+1);
end
end

inter_index = ceil((inter_bound+1)*(MAX-1)/2+1);
imag_index = ceil((imag_bound+1)*(MAX-1)/2+1);
index4 = ceil((max_bound+1)*(MAX-1)/2+1);

index1 = max(inter_index,imag_index); %maximum index for c,d
index2 = min(imag_index,inter_index); %minimum index for c,d

if(condition)
index3=imag_index;
else
index3=inter_index;
end

actual_value1 = Gr(index1);
actual_value2 = Gr(index2);
actual_value3 = Gr(index3);
actual_value4 = Gr(index4);

if((actual_value1 > inter_bound & index1 == inter_index)|(actual_value1 > imag_bound & index1 == imag_index))
index1 = index1 - 1;
end
if((actual_value2 < inter_bound & index2 == inter_index)|(actual_value2 < imag_bound & index2 == imag_index))
index2 = index2 + 1;
end
if((actual_value3 < inter_bound & index3 == inter_index)|(actual_value3 < imag_bound & index3 == imag_index))
index3 = index3 + 1;
end
if(actual_value4 > max_bound)
index4 = index4 - 1;
end

MIN=index2;
MAX2=index1;
MAX3=index4;
MIN2 = index3;

% actual_value1 = Gr(MIN);
% actual_value2 = Gr(MAX2);
% MIN=1;
% MAX2=MAX;
% MIN2=1;

x_L_a = real(1/2/X*(-2+2*(1-X^2+2*X^2.*Gr(MIN2:MAX3)-X^2.*Gr(MIN2:MAX3).^2).^(1/2)));
x_L_b = real(1/2/X*(2-2*(1-X^2+2*X^2.*Gr(MIN2:MAX3)-X^2.*Gr(MIN2:MAX3).^2).^(1/2)));
x_L_c= real(1/2/X*(2+2*(1-X^2+2*X^2.*Gr(MIN:MAX2)-X^2.*Gr(MIN:MAX2).^2).^(1/2)));
x_L_d= real(1/2/X*(-2-2*(1-X^2+2*X^2.*Gr(MIN:MAX2)-X^2.*Gr(MIN:MAX2).^2).^(1/2)));

if(MIN2<MAX3)
x_L_c(1)=x_L_b(1);
x_L_d(1)=x_L_a(1);
end

check1 = abs(round(10000*1/2/X*(-2-2*(1-X^2+2*X^2*inter_bound-X^2*inter_bound^2)^(1/2))));
check2 = abs(round(10000*(1-inter_bound^2)^(1/2)));

if(imag_bound > -1 & check1 == check2)
plot(Gr(MIN:MAX2),x_L_c,'g')
plot(Gr(MIN:MAX2),x_L_d,'g')
end

plot(Gr(MIN2:MAX3),x_L_a,'g')
plot(Gr(MIN2:MAX3),x_L_b,'g')

condition = Gr(MIN2)^2 + x_L_d(1)^2 > .985;
if(X<=1)
if(mod(X,.1)==0)
if(mod(X,1)==0)
word = [num2str(X) '.0'];
else
word = num2str(X);
end
if(X==1)
angle = 90;
else
angle = -atan(angle_point)*180/pi;
end
set(text(Gr(MIN2),x_L_d(1),word),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MIN2),-x_L_d(1),word),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
if(mod(X,.2)==0)
xval=X^2/(X^2+4);
yval = 1/2/X*(-2+2*(1-X^2+2*X^2*xval-X^2*xval^2)^(1/2));
angle = -atan(yval/(.5-xval))*180/pi;
set(text(xval,yval,word),'Rotation',angle,'HorizontalAlignment','left','VerticalAlignment','bottom');
set(text(xval,-yval,word),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom')
end
end
elseif(X<=2)
if(mod(X,.2)==0)
if(mod(X,1)==0)
word = [num2str(X) '.0'];
else
word = num2str(X);
end
if(condition)
angle = -atan(angle_point)*180/pi+180;
set(text(Gr(MIN2),x_L_a(1),word),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MIN2),-x_L_a(1),word),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
else
angle = -atan(angle_point)*180/pi+180;
set(text(Gr(MAX2),x_L_d(length(x_L_d)),word),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MAX2),-x_L_d(length(x_L_d)),word),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
end
end
elseif(X<=5)
if(mod(X,1)==0)
if(condition)
angle = -atan(angle_point)*180/pi+180;
set(text(Gr(MIN2),x_L_a(1),[num2str(X) '.0']),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MIN2),-x_L_a(1),[num2str(X) '.0']),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
else
angle = -atan(angle_point)*180/pi+180;
set(text(Gr(MAX2),x_L_d(length(x_L_d)),[num2str(X) '.0']),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MAX2),-x_L_d(length(x_L_d)),[num2str(X) '.0']),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
end
end
else
if(mod(X,10)==0)
if(condition)
angle = -atan(angle_point)*180/pi+180;
set(text(Gr(MIN2),x_L_a(1),num2str(X)),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MIN2),-x_L_a(1),num2str(X)),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
else
angle = -atan(angle_point)*180/pi+180;
set(text(Gr(MAX2),x_L_d(length(x_L_d)),num2str(X)),'Rotation',angle,'VerticalAlignment','bottom','HorizontalAlignment','left');
set(text(Gr(MAX2),-x_L_d(length(x_L_d)),num2str(X)),'Rotation',-angle+180,'HorizontalAlignment','right','VerticalAlignment','bottom');
end
end
end
end
%plot imaginary axis
plot(zeros(1,length(Gr)),Gr,'r');

wavelengths = 0:.01:.5;
angle = linspace(pi,-pi,length(wavelengths));
wave_circle = 1.05*exp(j*phaseAngle);
plot(real(wave_circle),imag(wave_circle),'r');

for i=1:length(wavelengths)-1,
x=real(1.025*exp(j*angle(i)));
y=imag(1.025*exp(j*angle(i)));
if(x>0)
rot_angle=atan(y/x)*180/pi-90;
else
rot_angle=atan(y/x)*180/pi+90;
end
if(wavelengths(i)==0)
word = '0.00';
elseif(mod(wavelengths(i),.1)==0)
word = [num2str(wavelengths(i)) '0'];
else
word = num2str(wavelengths(i));
end
set(text(x,y,word),'Rotation',rot_angle,'VerticalAlignment','middle','HorizontalAlignment','center');
end

%plot reflection coefficient and line of intersection only if arguments are present

if(nargin == 2)
radius = abs((Zl-Zo)/(Zl+Zo));
Load_circle=radius*exp(j*phaseAngle);
plot(real(Load_circle),imag(Load_circle),'r');

slope = (-(1-radius^2)^(1/2)*radius)/(radius^2);

value=1/(1+slope^2)^(1/2);
MAX2 = ceil((value+1)*(MAX-1)/2+1);
actual_value = Gr(MAX2);
if(actual_value>value)
MAX2 = MAX2 - 1;
end

%plot line of intersection
line = slope*Gr(fix(MAX/2):MAX2);
plot(Gr(fix(MAX/2):MAX2),line,'r');
end

热心网友 时间:2023-08-22 10:45

本视频展示如何用matlab绘制散圆状态图,可用于相关科研数据绘图!

热心网友 时间:2023-08-22 10:46

http://www.programsalon.com/downloads75/sourcecode/graph/detail279125.html可以下载,不过要在这个网上先注册才可以下载源代码。

热心网友 时间:2023-08-22 10:46

csdn:
http://download.csdn.net/source/597969
源码搜搜:
http://www.codesoso.com/code/Smith-Chart.aspx
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
墨兰烂根是怎么回事 墨兰烂根后如何养护 谢绝推销参观拍照摄影看房预约 看房子为什么不让拍照 执业药师各科考试时间分配 执业药师考试倒计时100天,怎样备考最有效 中药执业药师怎么备考? 手机拒绝所有来电了怎么设置回来 美国狼人在伦敦演职员表 美国狼人在伦敦幕后制作 美国狼人在伦敦制作发行 2010年莒县廉租房名单 qq戳一戳在哪设置文字 别克无息贷款是针对哪城市的?今天听新闻说的 app听说是一个区域性的 针对自贡当地一个购物平台 都能购买不? 能够表达思念的字,除了思和忆谢谢 贷款买威朗自领,走别克金融七万两年免息好还是搞银行 古语中表示思念的字 什么兼职副业比较靠谱? 买别克英朗贷款可以贷几成?有无息贷款? NCE01H10和NCEP01T13有区别吗 现在四缸的别克英朗到底怎么样? 苇字的含义 在别克4S店买车 贷款8万第一年免息 贷款分5年还 一个月还多少钱 用一个字来表达想念是什么? 请问想买别克君越车,无息贷款有什么限制吗 2001年生的郑姓男孩,五行缺木少水,取浩苇这个名字好吗 男的名字最后一个字苇女的最后一个字菲 求取情侣名字 这两个字要包括 最好是个性点的额带几个特殊字符! 表达思念的单字? 属牛的男孩子取苇诚这个名字好不好? 康熙字典苇字起名学注解是什么阿 潮玩族闪购的余额是什么 付款约定和付款说明有什么区别 OPPO4G手机有用过的,推荐一款给我 表达思念的字谜 有什么关于想念的打字谜语吗? 华为南研所干部处胡家曙去哪里了? 巢湖市第一中学的现任领导 巢湖市第一中学的办学条件 付款说明怎么写 付款方式敲错情况说明怎么写? 河南一投资亿元的景区游客稀少,这个景区为何不受欢迎? 河南济源,投资亿元的一处景区游客稀少,你觉得该如何整改才能吸引游客? 投资一千个亿元可以把会东县打造成什么样+? 投资693.8亿元给甘肃省做什么? 某个项目今年约完成投资16.9亿元比去年的3倍少5.9亿元去年投资多少亿元? 2017年铁路固定资产投资了多少亿元? 投资3.85亿元建造,洪崖洞曾经无人问津为何现在却能爆红吸引千万游客? 投资15.15亿元&#47;年产能6万台 野马将新建山东新能源汽车生产基地 博郡投资3.9亿元扩充产能 将生产首款纯电动SUV 我怎么发现我的性格有点像女人的 怎么办呢