微波实验报告 smith原图 matlab

更新时间:2024-07-09 11:29:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

微波通信技术课程设计报告

Smith圆图软件

一:Smith圆图简要说明

用户输入阻抗实部与虚部在对应位置,以及特性阻抗。软件通过程序计算出导纳值、反射系数、相位、波长、驻波比、行波系数以及如何实现匹配,并显示在对应位置,其中实现匹配的方法显示在软件下方蓝色区域内;点击清楚图像可清楚归一化电阻圆、归一化电抗圆以及等反射系数圆;取点画图可在图像区域内根据鼠标确定点画出对应的归一化电阻圆等,以及显示导纳值等相关数据。单枝节匹配和双枝节匹配可根据输入的阻抗值和特性阻抗画出匹配图并标明对应点,其中单枝节匹配还可在下方显示出来具体的匹配方案。以上是该smith原图所有的功能。

二:Smith圆图的设计目的和要求

设计目的:

通过具体的软件编程和多媒体制作,进一步加深对微波通信技术的理解

和掌握,提高动手能力,提高解决实际问题的综合能力。 设计要求:

整个圆图软件分为用户图形界面模块、圆图计算模块、画图演示模块。上述: 大模块又进一步分解,其中用户图形界面模块分为:主页、主菜单;圆图计算模块分为反射系数计算、单支节匹配计算、输入阻抗计算以及整个Smith圆图;画图演示模块分为等归一化电阻圆、等归一化电抗圆、反射系数圆等;确定阻抗值在圆图上的位置、圆图的基本应用、求输入阻抗及其在圆图上的位置以及单支节匹配等问题。

三:Smith圆图的程序流程图

清除图像可根据需要在画图步骤后执行,清楚图像值清楚归一化电阻圆、归一化电抗圆等,并不清楚圆图的基本构架图

四:演示验证过程

输入阻抗和特性阻抗点击确定图:

点击清除图像后的图:

点击单枝节匹配图:

点击双枝节匹配图:

点击取点画图:

五:总结

1.心得体会:这次课设收获最多的觉得是matlab guide图像交互界面的使用与设计。这次程序的设计,明白了guide里面控件string、tag的重要性。在这次设计中,在网上找了两个程序做辅导,因为网上的资料并不需要figure就能成功运行,编程的方法不一样,所以通过自己各种查找资料(包括百度知道、百度文库、以及matlab技术论坛电子期刊等、)学习了guide的重要语句的使用,包括handles语句、str2double语句、set语句、delete语句的使用,明白了这几个基础语句的使用,在加上smith原理算法,从而成功的用自己的方法实现了smith原图的功能。

2.源程序:

function varargout = liujiaqingnew(varargin)

% LIUJIAQINGNEW MATLAB code for liujiaqingnew.fig

% LIUJIAQINGNEW, by itself, creates a new LIUJIAQINGNEW or raises the existing % singleton*.

%

% H = LIUJIAQINGNEW returns the handle to a new LIUJIAQINGNEW or the handle to

% the existing singleton*. %

% LIUJIAQINGNEW('CALLBACK',hObject,eventData,handles,...) calls the local

% function named CALLBACK in LIUJIAQINGNEW.M with the given input arguments. %

% LIUJIAQINGNEW('Property','Value',...) creates a new LIUJIAQINGNEW or raises the

% existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before liujiaqingnew_OpeningFcn gets called. An

% unrecognized property name or invalid value makes property application

% stop. All inputs are passed to liujiaqingnew_OpeningFcn via varargin. %

% *See GUI Options on GUIDE's Tools menu. Choose \only one

% instance to run (singleton)\ %

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help liujiaqingnew

% Last Modified by GUIDE v2.5 07-Jun-2013 00:23:26

% Begin initialization code - DO NOT EDIT gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @liujiaqingnew_OpeningFcn, ...

'gui_OutputFcn', @liujiaqingnew_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1}); end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else

gui_mainfcn(gui_State, varargin{:}); end

% End initialization code - DO NOT EDIT

% --- Executes just before liujiaqingnew is made visible.

function liujiaqingnew_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn. % hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to liujiaqingnew (see VARARGIN)

% Choose default command line output for liujiaqingnew handles.output = hObject;

% Update handles structure guidata(hObject, handles);

% UIWAIT makes liujiaqingnew wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = liujiaqingnew_OutputFcn(hObject, eventdata, handles)

% varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure varargout{1} = handles.output;

% --- Executes on button press in pushbutton7.

function pushbutton7_Callback(hObject, eventdata, handles) % hObject handle to pushbutton7 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA) %handles(axes1);

for R0=[0 0.2 0.5 1 2 ];

for X0=[-4 -2 -1 -0.5 -0.3 0.3 0.5 1 2 4];%循环输入归一化阻抗 tr=2*pi*(0:0.005:1); rr=1/(1+R0);cr=1-rr;

plot(cr+rr*cos(tr),rr*sin(tr),'g');%画电阻圆 axis square; hold on; x=X0;

rx=1/x;cx=rx;

tx=2*atan(x)*(0:0.01:1); if tx

plot(1-rx*sin(tx),cx-rx*cos(tx),'g')%画电抗圆 else

plot(1-rx*sin(tx),-cx-rx*cos(tx),'g') end

hold on; end end

t=-1:0.001:1;%画横轴 plot(t,0,'g'); axis square; hold on;

R0= get(handles.R ,'string');%提取电阻电抗值 X0 = get(handles.X ,'string'); Zo= get(handles.Zo ,'string'); R0=str2double(R0);%格式转换 转换为数值 X0=str2double(X0); Zo=str2double(Zo); %归一化 R=R0/Zo; X=X0/Zo;

%画smith图

U=(R^2+X^2-1)/(R^2+2*R+1+X^2);%转化为坐标值 即U V V=2*X/(R^2+2*R+1+X^2); tr=2*pi*(0:0.00001:1);

cosA=U/sqrt(U^2+V^2);%画相角线 sinA=V/sqrt(U^2+V^2); r0=0:0.00001:1;

g0=plot(r0*cosA,r0*sinA,'k','linewidth',1.5);

axis square; hold on;

rr=1/(1+R);cr=1-rr;

g1=plot(cr+rr*cos(tr),rr*sin(tr),'r','linewidth',1.5);%画电阻圆 axis square; hold on; x=X;

rx=1/x;cx=rx;

tx=2*atan(x)*(0:0.0001:1); if tx

g2=plot(1-rx*sin(tx),cx-rx*cos(tx),'m','linewidth',1.5);%画电抗圆 else

g3=plot(1-rx*sin(tx),-cx-rx*cos(tx),'m','linewidth',1.5); end

hold on;

r=sqrt(U^2+V^2);

g4=plot(r*cos(tr),r*sin(tr),'--','linewidth',1.5);% 等反射系数圆的半径

axis square; hold on;

G=R/(R^2+X^2);%导纳 B=-X/(R^2+X^2);

U=(R^2+X^2-1)/(R^2+2*R+1+X^2);%反射系数 V=2*X/(R^2+2*R+1+X^2);

zhu_bo_bi=(1+sqrt(U^2+V^2))/(1-sqrt(U^2+V^2));%驻波比 xing_bo_xi_shu=1/zhu_bo_bi; %行波系数 A0=atan(V/U); %相位角 if U<0

A=(180/pi)*(A0+pi); elseif V>=0

A=(180/pi)*A0; else

A=(180/pi)*(A0+2*pi); end if V>=0

L=(0.5/360)*(180-A); else

L=0.75-(0.5/360)*A;

end %波长数 %匹配问题

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

z=R+j*X;

Gamma2=(z-1)/(z+1); Mod=abs(Gamma2); Phi=angle(Gamma2); if X0<0

if(Phi>=0)

Lmin=Phi/(4*pi); Lmax=0.25+Lmin; else

Lmin=(pi+Phi)/(4*pi); Lmax=0.25+Lmin; end else

if(Phi>=0)

Lmax=Phi/(4*pi); Lmin=0.25+Lmax; else

Lmax=(pi+Phi)/(4*pi); Lmin=0.25+Lmax; end

hold off; end

rho=(1+abs(Gamma2))/(1-abs(Gamma2)); Zo1=Zo*sqrt(rho); Zo2=Zo/sqrt(rho);

set(handles.Ht5,'string',strcat('在L1=',num2str(Lmax),'λ处并接入特性阻抗为 Zo1 = ', num2str(Zo1),' Ω 的λ/4传输线可实现匹配'),'fontname','宋体','fontsize',12);

set(handles.Ht6,'string',strcat('或在L2=',num2str(Lmin),'λ处并接入特性阻抗为 Zo2 = ', num2str(Zo2),' Ω 的λ/4传输线可实现匹配'),'fontname','宋体','fontsize',12);

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

%显示各种参数值

G = num2str(G); % 转换为字符串 set(handles.G,'string',G); B = num2str(B); % 转换为字符串 set(handles.B,'string',B);

zhu_bo_bi= num2str(zhu_bo_bi); % 转换为字符串 set(handles.zhu_bo_bi,'string',zhu_bo_bi);

xing_bo_xi_shu = num2str(xing_bo_xi_shu); % 转换为字符串 set(handles.xing_bo_xi_shu,'string',xing_bo_xi_shu);

U = num2str(U); % 转换为字符串 set(handles.U,'string',U); V = num2str(V); % 转换为字符串 set(handles.V,'string',V); xw = num2str(A); % 转换为字符串 set(handles.xw,'string',xw); bc= num2str(L); % 转换为字符串 set(handles.bc,'string',bc);

guidata(hObject, handles); % 更新结构体

function X_Callback(hObject, eventdata, handles) % hObject handle to X (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) X= str2double(get(hObject,'String')); % string属性是字符串,所以必须转换成数值

% 检验输入是否为空,是则将它置为0 if (isempty(X))

set(hObject,'String','0') end

% 保存handles结构体,只要在handles结构体有改变时,才需要保存 guidata(hObject, handles);

% 这里由于handles没有改变,故这里其实没有必要,但是为了避免潜在的不必要麻烦, % 建议在所有Callback最后都添加该命令

% Hints: get(hObject,'String') returns contents of X as text

% str2double(get(hObject,'String')) returns contents of X as a double

% --- Executes during object creation, after setting all properties. function X_CreateFcn(hObject, eventdata, handles) % hObject handle to X (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function R_Callback(hObject, eventdata, handles) % hObject handle to R (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) R= str2double(get(hObject,'String')); % string属性是字符串,所以必须转换成数值

% 检验输入是否为空,是则将它置为0 if (isempty(R))

set(hObject,'String','0') end

% 保存handles结构体,只要在handles结构体有改变时,才需要保存 guidata(hObject, handles);

% 这里由于handles没有改变,故这里其实没有必要,但是为了避免潜在的不必要麻烦, % 建议在所有Callback最后都添加该命令

% Hints: get(hObject,'String') returns contents of R as text

% str2double(get(hObject,'String')) returns contents of R as a double

% --- Executes during object creation, after setting all properties. function R_CreateFcn(hObject, eventdata, handles) % hObject handle to R (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit26_Callback(hObject, eventdata, handles) % hObject handle to edit26 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit26 as text % str2double(get(hObject,'String')) returns contents of edit26 as a double

% --- Executes during object creation, after setting all properties. function edit26_CreateFcn(hObject, eventdata, handles) % hObject handle to edit26 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit27_Callback(hObject, eventdata, handles) % hObject handle to edit27 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit27 as text % str2double(get(hObject,'String')) returns contents of edit27 as a double

% --- Executes during object creation, after setting all properties. function edit27_CreateFcn(hObject, eventdata, handles) % hObject handle to edit27 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit28_Callback(hObject, eventdata, handles) % hObject handle to edit28 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit28 as text % str2double(get(hObject,'String')) returns contents of edit28 as a double

% --- Executes during object creation, after setting all properties. function edit28_CreateFcn(hObject, eventdata, handles) % hObject handle to edit28 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit29_Callback(hObject, eventdata, handles) % hObject handle to edit29 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit29 as text % str2double(get(hObject,'String')) returns contents of edit29 as a double

% --- Executes during object creation, after setting all properties. function edit29_CreateFcn(hObject, eventdata, handles) % hObject handle to edit29 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns

called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit30_Callback(hObject, eventdata, handles) % hObject handle to edit30 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit30 as text % str2double(get(hObject,'String')) returns contents of edit30 as a double

% --- Executes during object creation, after setting all properties. function edit30_CreateFcn(hObject, eventdata, handles) % hObject handle to edit30 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

% --- Executes on button press in togglebutton3.

function togglebutton3_Callback(hObject, eventdata, handles) % hObject handle to togglebutton3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of togglebutton3

function Zo_Callback(hObject, eventdata, handles) % hObject handle to Zo (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) Zo= str2double(get(hObject,'String')); % string属性是字符串,所以必须转换成数值

% 检验输入是否为空,是则将它置为0 if (isempty(Zo))

set(hObject,'String','0') end

% 保存handles结构体,只要在handles结构体有改变时,才需要保存 guidata(hObject, handles);

% Hints: get(hObject,'String') returns contents of Zo as text % str2double(get(hObject,'String')) returns contents of Zo as a double

% --- Executes during object creation, after setting all properties. function Zo_CreateFcn(hObject, eventdata, handles) % hObject handle to Zo (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

% --- Executes on button press in pushbutton10.

function pushbutton10_Callback(hObject, eventdata, handles)

delete(findobj('color','k'));delete(findobj('color','b'));delete(findobj('color','r'));delete(findobj('color','m')); delete(findobj('color','c'));

% hObject handle to pushbutton10 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton11.

function pushbutton11_Callback(hObject, eventdata, handles) % hObject handle to pushbutton11 (see GCBO) for R=[0 0.2 0.5 1 2 ];

for X=[-4 -2 -1 -0.5 -0.3 0.3 0.5 1 2 4];%循环输入归一化阻抗 tr=2*pi*(0:0.005:1); rr=1/(1+R);cr=1-rr;

plot(cr+rr*cos(tr),rr*sin(tr),'g');%画电阻圆 axis square; hold on; x=X;

rx=1/x;cx=rx;

tx=2*atan(x)*(0:0.01:1); if tx

plot(1-rx*sin(tx),cx-rx*cos(tx),'g')%画电抗圆 else

plot(1-rx*sin(tx),-cx-rx*cos(tx),'g') end

hold on; end end

t=-1:0.001:1;%画横轴 plot(t,0,'g'); axis square; hold on;

%鼠标定点数据获取于处理 [U,V]=ginput(1); if(( U^2+V^2)>1)

warndlg({'警告:您所取的点已超出圆图范围!','请重新取点!'},'警告'); else

R=(1-U^2-V^2)/((1-U)^2+V^2);%阻抗 X=2*V/((1-U)^2+V^2); tr=2*pi*(0:0.00001:1); %z=U+V*j;

cosA=U/sqrt(U^2+V^2); sinA=V/sqrt(U^2+V^2); r0=0:0.00001:1;

g0=plot(r0*cosA,r0*sinA,'k','linewidth',1.5);%画相角线 axis square; hold on;

rr=1/(1+R);cr=1-rr;

g1=plot(cr+rr*cos(tr),rr*sin(tr),'r','linewidth',1.5);%画电阻圆 axis square; hold on; x=X;

rx=1/x;cx=rx;

tx=2*atan(x)*(0:0.0001:1); if tx

g2=plot(1-rx*sin(tx),cx-rx*cos(tx),'m','linewidth',1.5);%画电抗圆 else

g3=plot(1-rx*sin(tx),-cx-rx*cos(tx),'m','linewidth',1.5); end

hold on;

r=sqrt(U^2+V^2);

g4=plot(r*cos(tr),r*sin(tr),'--','linewidth',1.5);% 等反射系数圆的半径

axis square;

hold on; %当有新的图形输入的时候 原来图形被清除,同时保证 第二次取点的时候背景保留。 G=R/(R^2+X^2);%导纳 B=-X/(R^2+X^2);

U=(R^2+X^2-1)/(R^2+2*R+1+X^2);%反射系数 V=2*X/(R^2+2*R+1+X^2);

zhu_bo_bi=(1+sqrt(U^2+V^2))/(1-sqrt(U^2+V^2));%驻波比 xing_bo_xi_shu=1/zhu_bo_bi; %行波系数 A0=atan(V/U); %相位角 if U<0

A=(180/pi)*(A0+pi); elseif V>=0

A=(180/pi)*A0; else

A=(180/pi)*(A0+2*pi); end if V>=0

L=(0.5/360)*(180-A); else

L=0.75-(0.5/360)*A;

end %波长数

%显示各种参数值

G = num2str(G); % 转换为字符串 set(handles.G,'string',G); B = num2str(B); % 转换为字符串

set(handles.B,'string',B);

zhu_bo_bi= num2str(zhu_bo_bi); % 转换为字符串 set(handles.zhu_bo_bi,'string',zhu_bo_bi);

xing_bo_xi_shu = num2str(xing_bo_xi_shu); % 转换为字符串 set(handles.xing_bo_xi_shu,'string',xing_bo_xi_shu); U = num2str(U); % 转换为字符串 set(handles.U,'string',U); V = num2str(V); % 转换为字符串 set(handles.V,'string',V); xw = num2str(A); % 转换为字符串 set(handles.xw,'string',xw); bc= num2str(L); % 转换为字符串 set(handles.bc,'string',bc);

guidata(hObject, handles); % 更新结构体 end

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton12.

function pushbutton12_Callback(hObject, eventdata, handles) % hObject handle to pushbutton12 (see GCBO) %计算并联支节的位置和短路及开路支节的长度 Hdata=get(gcf,'userdata');

%计算并联支节的位置和短路及开路支节的长度

R0= get(handles.R ,'string');%提取电阻电抗值 X0 = get(handles.X ,'string'); Zo= get(handles.Zo ,'string');

R0=str2double(R0);%格式转换 转换为数值 X0=str2double(X0); Zo=str2double(Zo); r=R0/Zo; x=X0/Zo; if R0==Zo m=-x/2;

B=(R0^2*m-(Zo-X0*m)*(Zo+X0*m))/(Zo*(R0^2+(Zo+X0*m)^2)); if m>=0

d1=atan(m)/(2*pi); if d1>=0.5

d1=d1-0.5; elseif d1<0 d1=d1+0.5; else

d1=d1;

end

d2=atan(m)/(2*pi); if d2>=0.5

d2=d2-0.5; elseif d2<0 d2=d2+0.5; else

d2=d2; end

Lo1=(-atan(B*Zo))/(2*pi); if Lo1>=0 Lo1=Lo1; Lo2=Lo1; else

Lo1=0.5+Lo1; Lo2=Lo1; end

Ls1=(atan(1/(B*Zo)))/(2*pi); if Ls1>=0 Ls1=Ls1; Ls2=Ls1; else

Ls1=0.5+Ls1; Ls2=Ls1; end else

d1=(atan(m)+pi)/(2*pi); if d1>=0.5

d1=d1-0.5; elseif d1<0 d1=d1+0.5; else

d1=d1; end

d2=(atan(m)+pi)/(2*pi); if d2>=0.5

d2=d2-0.5; elseif d2<0 d2=d2+0.5; else

d2=d2; end

Lo1=(-atan(B*Zo))/(2*pi); if Lo1>=0

Lo1=Lo1; Lo2=Lo1; else

Lo1=0.5+Lo1; Lo2=Lo1; end

Ls1=(atan(1/(B*Zo)))/(2*pi); if Ls1>=0 Ls1=Ls1; Ls2=Ls1; else

Ls1=0.5+Ls1; Ls2=Ls1; end end else

m1=(X0+sqrt(R0*((Zo-R0)^2+X0^2)/Zo))/(R0-Zo); m2=(X0-sqrt(R0*((Zo-R0)^2+X0^2)/Zo))/(R0-Zo);

B1=(R0^2*m1-(Zo-X0*m1)*(X0+Zo*m1))/(Zo*(R0^2+(X0+Zo*m1)^2)); B2=(R0^2*m2-(Zo-X0*m2)*(X0+Zo*m2))/(Zo*(R0^2+(X0+Zo*m2)^2)); Lo1=(-atan(B1*Zo))/(2*pi); if Lo1>=0 Lo1=Lo1; else

Lo1=0.5+Lo1; end

Lo2=(-atan(B2*Zo))/(2*pi); if Lo2>=0 Lo2=Lo2; else

Lo2=0.5+Lo2; end

Ls1=(atan(1/(B1*Zo)))/(2*pi); if Ls1>=0 Ls1=Ls1; else

Ls1=0.5+Ls1; end

Ls2=(atan(1/(B2*Zo)))/(2*pi); if Ls2>=0 Ls2=Ls2; else

Ls2=0.5+Ls2; end

if m1>=0

d1=atan(m1)/(2*pi); if d1>=0.5

d1=d1-0.5; elseif d1<0 d1=d1+0.5; else

d1=d1; end

d2=(atan(m2)+pi)/(2*pi); if d2>=0.5

d2=d2-0.5; elseif d2<0 d2=d2+0.5; else

d2=d2; end else

d1=(atan(m1)+pi)/(2*pi); if d1>=0.5

d1=d1-0.5; elseif d1<0 d1=d1+0.5; else

d1=d1; end

d2=atan(m2)/(2*pi); if d2>=0.5

d2=d2-0.5; elseif d2<0 d2=d2+0.5; else

d2=d2; end end end

hold off;

%归一化阻抗和确定传播状态

R0= get(handles.R ,'string');%提取电阻电抗值 X0 = get(handles.X ,'string'); Zo= get(handles.Zo ,'string'); R0=str2double(R0);%格式转换 转换为数值 X0=str2double(X0); Zo=str2double(Zo);

r=R0/Zo; x=X0/Zo; z=r+i*x; y=1/z;

g=real(y); b=imag(y);

Gamma2=(z-1)/(z+1); Mod=abs(Gamma2); Phi=angle(Gamma2);

Lambda=(pi-Phi)/(4*pi); Alpha=(y-1)/(y+1);

plot(real(Alpha),imag(Alpha),'gp'); hold on;

plot(real(Gamma2),imag(Gamma2),'gp'); hold on;

aa=[real(Alpha),real(Gamma2)]; bb=[imag(Alpha),imag(Gamma2)]; polyfit(aa,bb,1); plot(aa,bb,'g'); hold on;

if X0<0

if(Phi>=0)

Lmin=Phi/(4*pi); Lmax=0.25+Lmin; else

Lmin=(pi+Phi)/(4*pi); Lmax=0.25+Lmin; end else

if(Phi>=0)

Lmax=Phi/(4*pi); Lmin=0.25+Lmax; else

Lmax=(pi+Phi)/(4*pi); Lmin=0.25+Lmax; end end

%画出单位圆和标出电刻度 t=0:0.0001:2*pi;

plot(cos(t),sin(t),'--g');

hold on;

plot([-1,1],[0,0],'g'); hold on;

plot([0,0],[-1,1],'g'); hold on;

axis('equal',[-1,1,-1,1]);

%画出等G圆 if g==inf

plot(1,0,'rp');

axis('equal',[-1,1,-1,1]); else

a=g/(1+g); g1=1/(1+g);

plot((g1*cos(t)+a),(g1*sin(t)),'r'); axis('equal',[-1,1,-1,1]); hold on; end;

%画出等B圆 if b==inf

plot(1,0,'rp');

axis('equal',[-1,1,-1,1]); elseif b==0

plot([-1,1],[0,0],'r'); axis('equal',[-1,1,-1,1]); else

b1=1/b; r2=1/b;

plot((r2*cos(t)+1),(r2*sin(t)+b1),'m'); axis('equal',[-1,1,-1,1]); hold on; end;

%画出等反射圆和匹配圆 y=g+j*b;

gamma=(y-1)/(y+1); Mod=abs(gamma); Phi=angle(gamma);

plot(Mod*cos(t),Mod*sin(t),'b'); hold on;

axis('equal',[-1,1,-1,1]);

plot(0.5*(cos(t)+1),(0.5*sin(t)),'c'); hold off; hold on;

%归一化及计参数

R0= get(handles.R ,'string');%提取电阻电抗值

X0 = get(handles.X ,'string'); Zo= get(handles.Zo ,'string');

R0=str2double(R0);%格式转换 转换为数值 X0=str2double(X0); Zo=str2double(Zo); r=R0/Zo; x=X0/Zo; z=r+i*x; y=1/z;

Alpha=atan2(imag(Gamma2),real(Gamma2)); alpha1=(y-1)/(y+1);

%计算匹配点位置 if R0==Zo

plot(real(Gamma2),imag(Gamma2),'rp'); plot(real(Gamma2),-imag(Gamma2),'rp'); m=[0,real(Gamma2)]; Re1=[0,cos(Alpha)]; Im1=[0,sin(Alpha)]; Im2=[0,-sin(Alpha)]; plot(Re1,Im1,'r'); plot(Re1,Im2,'r'); hold off; else

angle1=abs(atan2(imag(Gamma2),real(Gamma2))); angle2=2*pi*(d1/0.5)-angle1; if X0>=0

if angle2<0

angle2=2*pi+angle2;

plot(-abs(Gamma2)*cos(angle2),abs(Gamma2)*sin(angle2),'rp');

plot(-abs(Gamma2)*cos(angle2),-abs(Gamma2)*sin(angle2),'rp'); Re3=[0,cos(angle2)]; Re4=[0,cos(angle2)]; Im3=[0,sin(angle2)]; Im4=[0,-sin(angle2)]; plot(-Re3,Im3,'r'); plot(-Re4,Im4,'r'); hold off; else

angle2=angle2;

plot(-abs(Gamma2)*cos(angle2),abs(Gamma2)*sin(angle2),'rp');

plot(-abs(Gamma2)*cos(angle2),-abs(Gamma2)*sin(angle2),'rp'); Re3=[0,cos(angle2)]; Re4=[0,cos(angle2)]; Im3=[0,sin(angle2)]; Im4=[0,-sin(angle2)]; plot(-Re3,Im3,'r'); plot(-Re4,Im4,'r'); hold off; end else

angle1=abs(atan2(imag(Gamma2),real(Gamma2))); angle2=2*pi*(d1/0.5)+angle1-2*pi; if angle2<0

angle2=2*pi+angle2;

plot(-abs(Gamma2)*cos(angle2),abs(Gamma2)*sin(angle2),'rp');

plot(-abs(Gamma2)*cos(angle2),-abs(Gamma2)*sin(angle2),'rp'); Re3=[0,cos(angle2)]; Re4=[0,cos(angle2)]; Im3=[0,sin(angle2)]; Im4=[0,-sin(angle2)]; plot(-Re3,Im3,'r'); plot(-Re4,Im4,'r'); hold off; else

angle2=angle2;

plot(-abs(Gamma2)*cos(angle2),abs(Gamma2)*sin(angle2),'rp');

plot(-abs(Gamma2)*cos(angle2),-abs(Gamma2)*sin(angle2),'rp'); Re3=[0,cos(angle2)]; Re4=[0,cos(angle2)]; Im3=[0,sin(angle2)]; Im4=[0,-sin(angle2)]; plot(-Re3,Im3,'r'); plot(-Re4,Im4,'r'); hold off; end end end

hold off;

rho=(1+abs(Gamma2))/(1-abs(Gamma2));

if R0==Zo

set(handles.Ht5,'string',strcat('在d1 = ',num2str(d1),'λ处并接入Lo = ',num2str(Lo1),'λ 的短路支节可实现匹配'),'fontname','宋体','fontsize',10);

set(handles.Ht6,'string',strcat('或在d2 = ',num2str(d2),'λ处并接入Ls = ',num2str(Ls1),'λ 的开路支节实现匹配'),'fontname','宋体','fontsize',10); else

set(handles.Ht5,'string',strcat('在d1 = ',num2str(d1),'λ处并接入长度为Ls = ',num2str(Ls1),'λ 的短路支节','或Lo = ',num2str(Lo1),'λ 的开路支节可实现匹配'),'fontname','宋体','fontsize',10);

set(handles.Ht6,'string',strcat('或在d2 = ',num2str(d2),'λ处并接入长度为Ls = ',num2str(Ls2),'λ 的短路支节','或Lo = ',num2str(Lo2),'λ 的开路支节可实现匹配'),'fontname','宋体','fontsize',10); end

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% --- Executes on button press in pushbutton13.

function pushbutton13_Callback(hObject, eventdata, handles) % hObject handle to pushbutton13 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) R0= get(handles.R ,'string');%提取电阻电抗值 X0 = get(handles.X ,'string'); Zo= get(handles.Zo ,'string'); R0=str2double(R0);%格式转换 转换为数值 X0=str2double(X0); Zo=str2double(Zo); Z=R0+i*X0; Y=1/Z; Yo=1/Zo; G=real(Y); B=imag(Y); m=1;

%两支节相距λ/8

m1=(1+m^2)*G*Yo-G^2*m^2; m2=abs(1+m^2)*G*Yo-G^2*m^2; B11=-B+(Yo+sqrt(m1))/m;

B21=(Yo*sqrt(m2)+G*Yo)/(G*m); B12=-B+(Yo-sqrt(m1))/m;

B22=(-Yo*sqrt(m2)+G*Yo)/(G*m); Ls=-(atan(Yo/B11))/(2*pi); if Ls>=0

Ls11=Ls; else

Ls11=0.5+Ls; end

Ls=-(atan(Yo/B21))/(2*pi); if Ls>=0

Ls21=Ls; else

Ls21=0.5+Ls; end

Ls=-(atan(Yo/B12))/(2*pi); if Ls>=0

Ls12=Ls; else

Ls12=0.5+Ls; end

Ls=-(atan(Yo/B22))/(2*pi); if Ls>=0

Ls22=Ls; else

Ls22=0.5+Ls; end

hold off; r=R0/Zo; x=X0/Zo; z=r+i*x; y=1/z;

g=real(y); b=imag(y);

Gamma2=(z-1)/(z+1); Mod=abs(Gamma2); Phi=angle(Gamma2);

Lambda=(pi-Phi)/(4*pi); Alpha=(y-1)/(y+1);

plot(real(Alpha),imag(Alpha),'gp');

hold on;

plot(real(Gamma2),imag(Gamma2),'gp'); hold on;

aa=[real(Alpha),real(Gamma2)]; bb=[imag(Alpha),imag(Gamma2)]; polyfit(aa,bb,1); plot(aa,bb,'g'); hold on; if X0<0

if(Phi>=0)

Lmin=Phi/(4*pi); Lmax=0.25+Lmin; else

Lmin=(pi+Phi)/(4*pi); Lmax=0.25+Lmin; end else

if(Phi>=0)

Lmax=Phi/(4*pi); Lmin=0.25+Lmax; else

Lmax=(pi+Phi)/(4*pi); Lmin=0.25+Lmax; end end

%画出单位圆和标出电刻度 t=0:0.0001:2*pi;

plot(cos(t),sin(t),'--g');

text (-1.2,0,'0', 'fontname', 'arial','color','b', 'fonta', 'italic');

text (-0.1,1.03,'0. 125', 'fontname', 'arial','color','b', 'fonta', 'italic');

text (1.03,0,'0.25', 'fontname', 'arial','color','b', 'fonta', 'italic'); text (-0.1, -1.18, '0.375', 'fontname', 'arial','color','b', 'fonta', 'italic'); hold on;

plot([-1,1],[0,0],'g'); hold on;

plot([0,0],[-1,1],'g'); hold on;

axis('equal',[-1,1,-1,1]); %画出等G圆 if g==inf

plot(1,0,'rp');

axis('equal',[-1,1,-1,1]); else

a=g/(1+g); g1=1/(1+g);

plot((g1*cos(t)+a),(g1*sin(t)),'r'); axis('equal',[-1,1,-1,1]); hold on; end;

%画出等B圆 if b==inf

plot(1,0,'rp');

axis('equal',[-1,1,-1,1]); elseif b==0

plot([-1,1],[0,0],'r'); axis('equal',[-1,1,-1,1]); else

b1=1/b; r2=1/b;

plot((r2*cos(t)+1),(r2*sin(t)+b1),'m'); axis('equal',[-1,1,-1,1]); hold on; end;

%画出等反射圆和匹配圆 y=g+j*b;

gamma=(y-1)/(y+1); Mod=abs(gamma); Phi=angle(gamma);

plot(Mod*cos(t),Mod*sin(t),'b'); hold on;

axis('equal',[-1,1,-1,1]);

plot(0.5*(cos(t)+1),(0.5*sin(t)),'c'); hold off; hold on;

if imag(Ls11)==0 & imag(Ls12)==0 imag(Ls22)==0

t=0:0.0001:2*pi;

plot(0.5*(cos(t)),(0.5*sin(t)+0.5),'c'); hold on; r=R/Zo; x=X/Zo; z=r+i*x; y=1/z;

g=real(y);

imag(Ls21)==0 & &

b=imag(y);

%计算并画出第二支节的匹配点位置 x1=-tan(2*pi*Ls21); x2=-tan(2*pi*Ls22); y1=1+i*(1/x1); y2=1+i*(1/x2);

gamma1=(y1-1)/(y1+1); gamma2=(y2-1)/(y2+1); aa1=real(gamma1); bb1=-imag(gamma1); aa2=real(gamma2); bb2=-imag(gamma2); plot(aa1,bb1,'rp'); plot(aa2,bb2,'rp'); alpha1=atan2(bb1,aa1); alpha2=atan2(bb2,aa2); Re1=[0,cos(alpha1)]; Re2=[0,cos(alpha2)]; Im1=[0,sin(alpha1)]; Im2=[0,sin(alpha2)]; plot(Re1,Im1,'r'); plot(Re2,Im2,'r');

%计算并画出第一支节的匹配点位置

plot(abs(gamma1)*cos(alpha1+pi/2),abs(gamma1)*sin(alpha1+pi/2),'bp');

plot(abs(gamma2)*cos(alpha2+pi/2),abs(gamma2)*sin(alpha2+pi/2),'bp');

Re3=[0,cos(alpha1+pi/2)]; Re4=[0,cos(alpha2+pi/2)]; Im3=[0,sin(alpha1+pi/2)]; Im4=[0,sin(alpha2+pi/2)]; plot(Re3,Im3,'b'); plot(Re4,Im4,'b'); hold off;

else

t=0:0.0001:2*pi;

plot(0.5*(cos(t)),(0.5*sin(t)+0.5),'c'); hold on;

[Gamma2,Lmin,Lmax]=circlefun(R,X,Zo); axis('equal',[-1,1,-1,1]); hold off; end

hold off;

rho=(1+abs(Gamma2))/(1-abs(Gamma2));

if imag(Ls11)==0 & imag(Ls12)==0 & imag(Ls21)==0 & imag(Ls22)==0

set(handles.Ht5,'string',strcat(' 在负载处并入长度为',num2str(Ls11),'λ 的短路支节,再在d=λ/ 8处并入长度为',num2str(Ls21),'λ 的短路支节就可实现匹配'),'fontname','宋体','fontsize',10);

set(handles.Ht6,'string',strcat(' 或在负载处并入长度为',num2str(Ls12),'λ 的短路支节,再在d=λ/ 8处并入长度为',num2str(Ls22),'λ 的短路支节就可实现匹配'),'fontname','宋体','fontsize',10); else

set(handles.Ht5,'string',strcat(' WARNING ! 等 G 圆与λ/ 8辅助圆无交点'),'fontname','宋体','fontsize',10);

set(handles.Ht6,'string',strcat(' 双支节匹配出现盲区!'),'fontname','宋体','fontsize',10); end

function V_Callback(hObject, eventdata, handles) % hObject handle to V (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of V as text

% str2double(get(hObject,'String')) returns contents of V as a double

% --- Executes during object creation, after setting all properties. function V_CreateFcn(hObject, eventdata, handles) % hObject handle to V (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function U_Callback(hObject, eventdata, handles) % hObject handle to U (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of U as text

% str2double(get(hObject,'String')) returns contents of U as a double

% --- Executes during object creation, after setting all properties. function U_CreateFcn(hObject, eventdata, handles) % hObject handle to U (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

function edit40_Callback(hObject, eventdata, handles) % hObject handle to edit40 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit40 as text % str2double(get(hObject,'String')) returns contents of edit40 as a double

% --- Executes during object creation, after setting all properties. function edit40_CreateFcn(hObject, eventdata, handles) % hObject handle to edit40 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB

% handles empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

3.参考资料:

【1】胡鹤飞.Matlab及其应用.北京邮电大学出版社.2012

【2】董金明,林萍实,邓晖.微波技术(第二版).机械工业出版社.2009 【3】Matlab技术论坛 http://www.ilovematlab.cn/ 【4】pudn程序员联合开发网 http://www.pudn.com/ 【5】百度文库 matlab GUI 快速入门

本文来源:https://www.bwwdw.com/article/4n2.html

Top