基于matlab史密斯圆图演示源码程序

218 篇文章 55 订阅
这是一个MATLAB脚本,用于计算给定频率下,基于特征阻抗的串联/并联或并联/串联2元件匹配网络。用户可以输入所需的归一化阻抗的实部和虚部,脚本将生成相应的反射系数,并在Smith图上显示。根据反射系数,脚本会找到4种可能的匹配方案:串联电感与并联电容、串联电感与并联电感、串联电容与并联电感、串联电容与并联电容。最后,它会验证计算出的匹配网络是否确实实现了所需阻抗。
摘要由CSDN通过智能技术生成

%tw0_elelment_matching.m
%This is a file to calculate series/shunt or shunt/series 
%2 element matching components from a given
%normalized impedance at a specific frequency.
%the characteristic impedance is selectable
%all calculations are done with normalized impdeances
% John Wetters
clear all
close all
delete diary.txt
diary diary.txt
echo on 

j=sqrt(-1) %use j as the complex operator to keep 
           %consistent with electronic literature on this subject

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%input section for characteristic impedance Zo
%input section for frequency of operation in Mhz
%input section for real part of desired impedance
%input section for imaginary part of desired impedance

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

z=input('What is the characteristic impedance Zo?   ','s')
if isempty(z)
    z = '50';
end
Zo=str2num(z)

freq=input('What is the frequency of the network in Mhz?  ','s')
if isempty(freq)
    freq = '150';
end
s5=[ freq 'Mhz']
f=str2num(freq)*1e6

w=2*pi*f %calculate omega, w from frequency of operation

zr=input('What is the real part of the normalized impedance needed?   ','s')
if isempty(zr)
    zr = '.1';
end
z1=str2num(zr)


zi=input('What is the imaginary part of the normalized impedance needed?   ','s')
if isempty(zi)
    zi = '.6';
end
z2=str2num(zi)


zcomplex=z1+j*z2 %this is the desired impedance
gama=(zcomplex-1)/(zcomplex+1) %this is the desired reflection coefficient

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%plot the reflection coefficient on the Smith chart
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

figure(1)
smith3
plot(gama,'rx')
title('normalized desired complex impedance')
s3=['  z=' zr '+j' zi]
text(real(gama),imag(gama),s3)
ycomplex=1/zcomplex %this is the needed complex admittance
mag=abs(gama)
angle1=180/pi*angle(gama) %angle in degrees
xlabel(['y desired=' num2str(ycomplex) '   gama desired= ' num2str(mag) ' deg=' num2str(angle1)])


%intersections to the 1+/-js admittance circle
%*******************************************
	s=sqrt(1/z1-1)
	yInterceptP=1+j*s
    yInterceptM=1-j*s
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
%intersections to the 1+/-jX impedance circle
%*******************************************   
    zInterceptM=1/yInterceptP
    zInterceptP=1/yInterceptM
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
%impdeances to rotate from the  1+/-js admittance circle
%*******************************************
	deltaZP=imag(zInterceptP)-z2
    deltaZM=imag(zInterceptM)-z2
    
   
if (deltaZP > 0 & imag(s)==0) % Shunt L Series C zInterceptP
	%case1
	shuntL=Zo/(s*w)
    seriesC=1/(w*abs(deltaZP*Zo))
	figure(2)
	smith3
	gama1=(zInterceptP-1)/(zInterceptP+1) %reflection coeffients of the interscetion to 1+js
	t=num2str(s);
	s4=[ '  Y=1 - j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4) %plot intersection point
    s1=['Shunt L ' num2str(shuntL) '  Series C '  num2str(seriesC)] %list 2 element match on figure
	title(s1)
	plot(gama,'rx') %plot desired complex impedance
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
    %check solution
    [zTest]=shuntL_seriesC(shuntL,seriesC,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
    
    %*******************************************
elseif (deltaZP < 0 & imag(s)==0) % Shunt L Series L zInterceptP
	%case2
	shuntL=Zo/(w*s)
    seriesL=abs(deltaZP*Zo)/w
	figure(3)
	smith3
	gama1=(zInterceptP-1)/(zInterceptP+1)
	t=num2str(s);
	s4=[ '  Y=1 - j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s1=['Shunt L ' num2str(shuntL) '  Series L '  num2str(seriesL)]
	title(s1)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
    [zTest]=shuntL_seriesL(shuntL,seriesL,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
    %*******************************************
end

    if (deltaZM < 0 & imag(s)==0) % Shunt C Series L zInterceptM
	%case3
    shuntC=s/(Zo*w)
    seriesL=abs(deltaZM*Zo)/w
	figure(4)
	smith3
	gama1=(zInterceptM-1)/(zInterceptM+1)
	t=num2str(s);
	s4=[ '  Y=1 +  j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s1=['Shunt C ' num2str(shuntC) '  Series L '  num2str(seriesL)]
	title(s1)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
    [zTest]=shuntC_seriesL(shuntC,seriesL,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
   
    %*******************************************
elseif (deltaZM > 0 & imag(s)==0) % Shunt C Series C zInterceptM
	%case4
	shuntC=s/(Zo*w)
    seriesC=1/(Zo*deltaZM*w)
	figure(5)
	smith3
	gama1=(zInterceptM-1)/(zInterceptM+1)
	t=num2str(s);
	s4=[ '  Y=1 + j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s1=['Shunt C ' num2str(shuntC) '  Series C '  num2str(seriesC)]
	title(s1)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
    [zTest]=shuntC_seriesC(shuntC,seriesC,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
   
    %*******************************************
end
		
%intersections to the 1+/-z circle
%Series L or C to shunt L or C
	z=sqrt(1/real(ycomplex)-1)
	zInterceptP=1+j*z
    zInterceptM=1-j*z
    yInterceptM=1/zInterceptP
    yInterceptP=1/zInterceptM
	deltaYP=imag(yInterceptP)-imag(ycomplex)
    deltaYM=imag(yInterceptM)-imag(ycomplex)
    %intersections to the 1+/-z circle

    %*******************************************
if (deltaYM < 0 & imag(z)==0 ) % Series L Shunt C zInterceptP
	%case1
    seriesL=abs(z*Zo)/w
    shuntC=abs(deltaYM)/(Zo*w)
	figure(6)
	smith3
	gama1=(zInterceptP-1)/(zInterceptP+1)
	t=num2str(z);
	s4=[ '  Z=1 +j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s=['Series L ' num2str(seriesL) '  Shunt C '  num2str(shuntC)]
	title(s)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
    [zTest]=seriesL_shuntC(seriesL,shuntC,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
    %*******************************************
elseif (deltaYM > 0 & imag(z)==0) % Series L Shunt L zInterceptP
	%case2
	seriesL=abs(z*Zo)/w
    shuntL=Zo/(abs(deltaYM)*w)
	figure(7)
	smith3
	gama1=(zInterceptP-1)/(zInterceptP+1)
	t=num2str(z);
	s4=[ '  Z=1 +j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s=['Series L ' num2str(seriesL) '  Shunt L '  num2str(shuntL)]
	title(s)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
     [zTest]=seriesL_shuntL(seriesL,shuntL,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
    %*******************************************
end

    if (deltaYP > 0 & imag(z)==0) % Series C Shunt L zInterceptM
	%case3
    seriesC=1/(Zo*z*w)
    shuntL=Zo/(abs(deltaYP)*w)
	figure(8)
	smith3
	gama1=(zInterceptM-1)/(zInterceptM+1)
	t=num2str(z);
	s4=[ '  Z=1 - j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s=['Series C ' num2str(seriesC) '  Shunt L '  num2str(shuntL)]
	title(s)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
    [zTest]=seriesC_shuntL(seriesC,shuntL,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
    %*******************************************
elseif (deltaYP < 0 & imag(z)==0) % Series C Shunt C zInterceptM
	%case4
    seriesC=1/(Zo*z*w)
	shuntC=abs(deltaYP)/(Zo*w)
	figure(9)
	smith3
	gama1=(zInterceptM-1)/(zInterceptM+1)
	t=num2str(z);
	s4=[ '  z=1 -j' t]
	plot(gama1,'rx')
	text(real(gama1),imag(gama1),s4)
    s=['Series C ' num2str(seriesC) '  Shunt C '  num2str(shuntC)]
	title(s)
	plot(gama,'rx')
	text(real(gama),imag(gama),s3)
	text(.5,1,s5)
     [zTest]=seriesC_shuntC(seriesC,shuntC,w,Zo)
    xlabel(['actual impdeance=' num2str(zTest)])
    %*******************************************
end	

	diary off
    edit diary.txt

 B16

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fpga和matlab

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值