您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 信息化管理 > smith圆图matlab代码
%VictorApreaCornellUniversity6/27/02%%Usage:plotsmithchart(Zl,Zo)%whereZlistheLoadImpedence(possiblycomplex)%andZoistheCharacteristicLineImpedence%Plotsasmithchart,alongwiththereflectioncoefficientcircle%andthelineofintersectionwithresistivecomponentequalto1.%plotsmithchart%Withoutanyparametersdrawsablanksmithchart.%Wavelengthstowardthegeneratorarelabeledaroundtheperimeter%%Forexample:plotsmithchart(25,50)%Drawsasmithchart,calculatesandplotsthereflectioncoefficient%foracharacteristicimpedenceof50ohmsandaloadimpedenceof25ohms,%anddrawsthelineofintersectionwiththeR=1circle.functionanswer=plotSmithChart(Zl,Zo);constant=linspace(0,10,5);phaseAngle=linspace(0,2*pi,50);unitGamma=exp(j*phaseAngle);%plottheunitcircleinthecomplexplaneholdon;plot(real(unitGamma),imag(unitGamma),'r');%set(gcf,'Position',[001280990]);axissquarezoomonaxis([-1.11.1-1.11.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);holdon;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]];%plotrealaxisplot(Gr,zeros(1,length(Gr)),'r');%equationswerederivedusingthesymbolictoolboxasfollows%solve('R=(1-Gr^2-Gi^2)/((1-Gr)^2+Gi^2)','Gi')%boundwasderivedasfollows%solve('1/(R+1)*(-(R+1)*(R-2*R*Gr+R.*Gr^2-1+Gr^2))^(1/2)=0','Gr')forR=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);elsemax_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);endendelseif(R1)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);elsemax_bound=(-1+1^2+R^2)/(1^2+R^2+2*R+1);endelseif(R5)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(R2)max_bound=(-1+5^2+R^2)/(5^2+R^2+2*R+1);elseif(mod(R,.2)==0)max_bound=(-1+5^2+R^2)/(5^2+R^2+2*R+1);elsemax_bound=(-1+2^2+R^2)/(2^2+R^2+2*R+1);endendelseif(R10)if(mod(R,2)==0)max_bound=(-1+20^2+R^2)/(20^2+R^2+2*R+1);elsemax_bound=(-1+10^2+R^2)/(10^2+R^2+2*R+1);endelseif(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(R20)max_bound=(-1+20^2+R^2)/(20^2+R^2+2*R+1);elsemax_bound=(-1+50^2+R^2)/(50^2+R^2+2*R+1);endendindex=ceil((min_bound1+1)*(MAX-1)/2+1);actual_value=Gr(index);if(actual_valuemin_bound1)index=index+1;endMIN=index;index=ceil((max_bound+1)*(MAX-1)/2+1);actual_value=Gr(index);if(actual_valuemax_bound)index=index-1;endMIN2=ceil((min_bound2+1)*(MAX-1)/2+1);actual_value=Gr(MIN2);if(actual_valuemin_bound2)MIN2=MIN2+1;endMAX2=ceil((max_bound2+1)*(MAX-1)/2+1);actual_value=Gr(MAX2);if(actual_valuemax_bound2)MAX2=MAX2+1;endr_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);%fixresolutionissuesin.2-.5rangeif(~(R.2&R.5&~(mod(R,.02)==0)))if(R==1)color='r';elsecolor='b';endplot(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'];elseword=num2str(R);endif(mod(R,.1)==0)set(text(Gr(MIN),0,word),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');endelseif(R=2)if(mod(R,.2)==0)if(mod(R,1)==0)word=[num2str(R)'.0'];elseword=num2str(R);endset(text(Gr(MIN),0,word),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');endelseif(R=5)if(mod(R,1)==0)set(text(Gr(MIN),0,[num2str(R)'.0']),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');endelseif(mod(R,10)==0)set(text(Gr(MIN),0,num2str(R)),'Rotation',90,'HorizontalAlignment','left','VerticalAlignment','bottom');endendelseif(R==.25|R==.35|R==.45)plot(Gr(MIN2:index),r_L_a3,'b');plot(Gr(MIN2:index),r_L_b3,'b');endif(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');endend%equationswerederivedusingthesymbolictoolboxasfollows%solve('2*Gi/((1-Gr)^2+Gi^2)=x','Gi')%boundwasderivedasfollows%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
本文标题:smith圆图matlab代码
链接地址:https://www.777doc.com/doc-5619600 .html