微波传输线三种工作状态分析的MATLAB实现
- 格式:docx
- 大小:262.14 KB
- 文档页数:18
MATLAB是一个强大的数学计算和图形绘制软件,可用于模拟和仿真电磁场与微波技术。
下面是一个简单的示例,展示如何在MATLAB中进行电磁场与微波技术的仿真:
matlab复制代码
% 创建一个2D网格
[x, y] = meshgrid(-10:0.1:10, -10:0.1:10);
% 定义一个随机的复高斯电场分布
E = 10^(5) * exp(-1i * pi * (x.^2 + y.^2));
% 计算电场的幅度和相位
E_real = real(E);
E_imag = imag(E);
% 绘制电场的幅度和相位图像
figure;
subplot(2, 1, 1);
imagesc(x, y, abs(E));
title('幅度');
colorbar;
subplot(2, 1, 2);
imagesc(x, y, atan(E_imag / E_real));
title('相位');
colorbar;
上述代码使用MATLAB创建了一个2D网格,并在该网格上定义了一个随机的复高斯电场分布。
然后,代码计算了电场的幅度和相位,并使用imagesc函数绘制了它们的图像。
在这个示例中,我们使用了一个简单的电场分布,但您可以根据需要修改代码以模拟更复杂的电磁场和微波技术。
利用MATLAB进行信号处理的技巧MATLAB作为一种功能强大的软件工具,被广泛用于信号处理领域。
利用MATLAB进行信号处理的技巧包括数据预处理、滤波和频谱分析、时频分析、信号重构以及信号特征提取等。
这些技巧可以帮助工程师和研究人员在处理和分析信号时更加高效和准确。
数据预处理是信号处理的第一步。
在使用MATLAB处理信号之前,通常需要对原始数据进行清洗和整理。
这包括去除噪声、异常点和干扰等。
MATLAB提供了一系列的函数和工具箱,如滤波器设计工具箱、统计工具箱等,可以帮助用户对数据进行降噪、修复和填补缺失值等操作。
滤波和频谱分析是信号处理的关键技术之一。
在MATLAB中,有多种滤波器可供选择,例如低通滤波器、高通滤波器、带通滤波器和带阻滤波器等。
这些滤波器可以通过设计滤波器系数或直接调用现成的滤波器函数来实现。
频谱分析可以帮助我们了解信号的频率成分以及其在不同频段上的能量分布。
MATLAB提供了FFT(快速傅里叶变换)等函数,可以对信号进行频谱分析并绘制功率谱密度图。
时频分析是一种用于研究信号在时间和频率上的变化的技术。
在MATLAB 中,时频分析常常使用短时傅里叶变换(STFT)、连续小波变换(CWT)和时域相关性分析等方法。
这些方法可以帮助我们观察信号的瞬时频谱特征,如频谱随时间变化的情况,从而揭示信号中的瞬态和周期性信息。
信号重构是指根据已有的数据或部分数据,通过一定的算法或模型来还原或预测信号的缺失或未来的数值。
在MATLAB中,可以利用插值、外推、拟合曲线等方法对信号进行重构。
这些方法基于信号的特征和统计信息进行计算,可以准确地估计未知数据或缺失数据的数值。
除了信号重构,信号特征提取也是信号处理中的重要一步。
通过提取信号的特征,我们可以了解到信号的统计特性、频域特性、时域特性等。
在MATLAB中,提取信号的特征通常使用统计学和谱分析等方法。
这些方法可以帮助我们提取信号的均值、方差、能量、峰值频率等特征,并用于信号分类、模式识别和故障检测等应用领域。
MATLAB中的信号调制与解调技巧随着科技的不断发展,无线通信越来越成为人们生活中不可或缺的一部分。
在无线通信系统中,信号调制与解调技巧起到至关重要的作用。
而MATLAB作为一种强大的工具,能够帮助工程师们在信号调制与解调方面进行深入研究和实践。
一、信号调制的基本原理与方法信号调制是将原始信号(baseband signal)通过改变某些参数来转换为调制信号(modulated signal)。
常见的信号调制方法包括幅度调制(AM)、频率调制(FM)和相位调制(PM)。
1.1 幅度调制幅度调制是一种通过改变信号的振幅来调制信号的方法。
MATLAB提供了丰富的函数和工具箱,可以方便地进行幅度调制的模拟和分析。
例如,我们可以使用MATLAB中的ammod函数来模拟幅度调制过程。
首先,我们需要准备一个原始信号,可以是一个正弦波或任何其他波形。
然后,通过设置调制指数(modulation index)来改变振幅。
最后,使用ammod函数对原始信号进行调制,生成调制后的信号。
1.2 频率调制频率调制是一种通过改变信号的频率来实现调制的方法。
以调幅电台为例,电台信号的频率会随着音频信号的变化而改变。
在MATLAB中,我们可以利用fmmod函数来模拟频率调制过程。
类似于幅度调制,我们需要先准备一个原始信号。
然后,通过设置调制指数和载波频率来改变频率。
最后,使用fmmod函数对原始信号进行调制,生成调制后的信号。
1.3 相位调制相位调制是一种通过改变信号的相位来实现调制的方法。
在数字通信系统中,相位调制常用于传输和提取数字信息。
MATLAB中的pmmod函数可以方便地实现相位调制。
与前两种调制方法类似,我们需要先准备一个原始信号。
然后,设置调制指数和载波频率来改变相位。
最后,使用pmmod函数对原始信号进行调制,生成调制后的信号。
二、信号解调的基本原理与方法信号解调是将调制信号恢复为原始信号的过程。
解调方法通常与调制方法相对应,常见的解调方法包括幅度解调(AM)、频率解调(FM)和相位解调(PM)。
微波传输线信号完整性分析与仿真摘要:随着对高速数字电路不断地深入研发,信号完整性越来越受到人们的关注,现已成为设计中必不可少的组成部分。
尤其在PCB设计阶段,大多数的约束都是建立在信号完整性分析的基础之上。
深入理解信号完整性方面的知识,有助于建立更为符合实际的约束的制定,同时也是进行信号完整性分析的必要条件。
本文就微波传输线信号完整性分析与仿真进行探讨。
关键词:微波传输线;信号完整性;仿真引言如今,高速系统的设计必须充分考虑到互连延迟引起的时序以及串扰、传输线效应等信号完整性问题。
元器件在CPB上的布局、元器件和CPB的参数、高速信号的布线等因素,都会引起信号完整性问题,进而导致系统工作不稳定,甚至无法工作。
所以,信号完整性问题越来越重要,已经引起电子工程师的高度重视。
本文将探讨信号完整性的基本概念以及如何基于IBIS模型对高速数据采集系统进行信号完整性仿真并利用仿真结果修改完善系统设计的问题。
一、基于IBIS模型的信号完整性分析信号完整性是指在信号线上的信号质量。
信号完整性故障会引起任意信号波形的跳变,导致把输人的畸变数据送人锁存,或在畸变的时钟跳变沿上造成在错误的时间捕获数据。
信号完整性分析的目的就是保证高速数据传输的可靠性。
1.1影晌信号完整性的主要因素影响信号完整性的主要因素有信号时延、反射与振铃、串扰、电磁兼容性或者电磁干扰(EMC/EMI)和电源/地噪声(地弹、Delta—I噪声或者同步开关噪声(SSN)等等。
传输时延与信号线的长度、信号传输速度的关系如下式中C为真空中的光速;reff为有效相对的介电常数;称为信号线的长度。
反射就是在传输线上的回波。
输人输出阻抗不匹配会引起反射,当信号在源端与负载端之间多次反射,在稳态信号上下产生的电压过冲和下冲现象,就是振铃。
串扰是指走线、导线、电缆束、元件以及任意其它易受电磁场干扰的电子元器件之间的不希望有的电磁祸合。
地弹指在电路中有大的电流涌动时,会引起地平面反弹噪声。
使用Matlab进行信号调制和解调技术信号调制和解调是通信系统中非常重要的环节,它们能够将原始信号转换为适合传输的调制信号,并在接收端将其恢复为原始信号。
Matlab是一种功能强大的工具,提供了丰富的信号处理函数和算法,可以方便地进行信号调制和解调的研究与实现。
本文将介绍如何使用Matlab进行信号调制和解调技术,并通过实例展示其在通信系统中的应用和效果。
一、调制技术概述调制技术是将需要传输的信息信号转换为载波信号的过程。
常见的调制技术包括幅度调制(AM)、频率调制(FM)和相位调制(PM)。
调制的目的是将低频信号转换为高频信号,使得信号能够在较长距离传输,并能够通过信道传输到接收端。
在Matlab中,可以使用内置函数如ammod、fmmod和pmmod来实现不同的调制技术。
以幅度调制为例,可以使用ammod函数来实现。
下面给出一个简单的幅度调制实例。
```matlabfs = 1000; % 采样频率t = 0:1/fs:1-1/fs; % 时间序列fc = 100; % 载波频率Ac = 1; % 载波幅度ym = sin(2*pi*10*t); % 原始信号ym_mod = ammod(ym, fc, fs, Ac); % 幅度调制```上述代码中,首先定义了采样频率fs、时间序列t、载波频率fc和载波幅度Ac。
然后,生成了一个原始信号ym,其中使用了sin函数生成了一个频率为10Hz的正弦波。
最后使用ammod函数对原始信号进行幅度调制,得到了调制后的信号ym_mod。
二、解调技术概述解调技术是将调制后的信号恢复为原始信号的过程。
解调技术主要包括幅度解调(AM)、频率解调(FM)和相位解调(PM)。
解调的目的是从调制信号中提取出原始信号,以实现信息的传输。
在Matlab中,可以使用内置函数如amdemod、fmdemod和pmdemod来实现不同的解调技术。
以幅度解调为例,可以使用amdemod函数来实现。
Matlab中的信号处理方法与示例分析引言:信号处理是指对信号进行采集、变换、压缩、恢复等操作的一种技术。
在现代科学和工程领域中,信号处理在音频、图像、视频等领域中有着广泛的应用。
Matlab作为一款功能强大的科学计算软件,提供了丰富的信号处理工具箱,方便用户进行信号处理的研究和应用。
本文将介绍Matlab中的信号处理方法以及一些示例分析。
一、时域分析1.基本信号生成:Matlab可以方便地生成各种基本信号,如正弦信号、方波信号、脉冲信号等。
利用Matlab编写的生成函数,可以通过输入参数来灵活生成所需的信号。
2.时域图像绘制:利用Matlab的图像绘制函数,可以将信号在时域上进行可视化表示。
通过绘制的时域图像,我们可以对信号的幅值、波形等特征进行直观的观察和分析。
3.时域运算:利用Matlab的向量化运算,我们可以对信号进行各种时域运算,如加法、减法、乘法、除法等。
这些操作对于研究信号的变换和传输过程具有重要的意义。
二、频域分析1.快速傅里叶变换(FFT):Matlab提供了方便的FFT函数,可以对信号进行频域分析,得到信号在频域上的表示。
通过FFT变换后的结果,我们可以得到信号的功率谱密度、频谱等信息。
2.频谱图绘制:Matlab中的频谱图绘制函数可以将信号的频谱绘制成直观的图像,帮助我们更好地理解信号的频率特征。
通过频谱图的分析,可以发现信号中的主要频率成分以及噪声等信息。
3.滤波操作:通过在频域上对信号进行滤波操作,可以实现信号的去噪、降噪等目的。
Matlab中提供了丰富的滤波函数和滤波器设计工具,方便用户进行信号滤波处理。
三、小波分析1.小波变换:小波变换是一种非平稳信号分析的有效方法。
Matlab中有多种小波变换函数,可以对信号进行小波变换,并得到信号在时频域上的表示。
小波变换可以更好地捕捉信号的瞬时特征,对于研究非平稳信号非常有用。
2.小波包分解:Matlab提供了小波包分解函数,可以将信号进行小波包变换,并得到信号在不同频带的分解系数。
基于MATLAB的微波传输状态仿真应用设计作者:王梦瑶来源:《西部论丛》2020年第08期摘要:微波指的是频率在300MHz至3000GHz的电磁波,最重要应用是雷达和通信。
雷达不仅用于国防,同时也用于导航、气象测量、工业检测和交通管理等方面。
通信应用主要是现代的卫星通信和常规的中继通信。
微波的三种传输状态,是微波传输理论分析的基础。
本文将针对微波传输的特性,利用MATLAB的RF模块设计出微波传输状态的仿真分析软件。
关键词:微波,仿真,matlab,传输状态一、微波简介微波是指频率在300MHz至3000GHz的电磁波。
由于特殊的频率,微波又被称为超高频电磁波,其对应波长为0.1mm到1米之间,是分米波、厘米波、毫米波与亚毫米波的统称。
微波凭借着独特的波长和频率,其波长范围和人类基本几何尺寸在同一个数量级,所以微波在通信和生活方面都有非常巨大的研究和应用的意义。
微波的基本性质通常呈现为穿透、反射、吸收三个特性。
其中,穿透性指的是微波相较于其他红外,远红外等用于加热的电磁波具有更长的波长,可以使介质材料内部、外部几乎同时加热升温,形成体热源状态,大大缩短了常规加热中的热传导时间[1];反射性指的是对于金属类的物质,微波不会穿透或者吸收,则是反射,故而,大量的波导结构均为金属波导;吸收特性则指的是对于水和食物等就会吸收微波而使自身发热[2]微波在通信中的应用主要体现在无线通信中。
微波作为无线通信的一个重要波段,其波长的长度决定了微波元器件的几何尺寸可以做到毫米级别,符合当前继承设备的要求。
在研究微波的过程中,主要有传统场论方法,化场为路的方法,以及网络化的方法。
其中,场论的方法最为准确,但同时也由于其涉及大量的电磁学理论,研究起来具有一定的难度;网络化的分析方法,则是利用黑盒理论,忽略微波元器件的几何结构以及内部场的变化,关注输入和输出的变化;化场为路的方法,则是将抽象的难以捕捉的微波传输过程等效为基本电路结构,通过路的理论和方法,对其进行研究。
(一)主程序变量说明:输入变量:zo 传输线特性阻抗zl 传输线终端负载阻抗Er 传输线介电常数f 传输电磁波的频率由输入变量计算得出的变量:w 传输电磁波的数字角频率len 传输电磁波的相波长beita 相移常数gama 传输线个点反射系数复值gamal 传输线终端反射系数的模rou 驻波系数k 行波系数Zi 传输线各点输入阻抗的复值Ui 传输线各点输入电压的复值Uo 传输线各点输出电压的复值Uit 传输线各点输入电压的瞬时值Uot 传输线各点输出电压的瞬时值Ii 传输线各点输入电流的复值Io 传输线各点输出电流的复值Is 传输线各点合成电流的复值Us 传输线各点合成电压的复值Ist 传输线各点合成电流的瞬时值Ust 传输线各点合成电压的瞬时值ph 传输线各点合成电压的相位(二)主程序流程说明:本程序的界面中共有三个输入编辑框,三个输出编辑框和五个波形显示窗口,分别用来输入:传输线特性阻抗Z0、传输线终端负载阻抗Z L、传输的电磁波的频率f、传输线传输介质的相对介电常数εr;输出:传输线的终端反射系数ΓL、行波系数ρ、驻波系数K;具体的程序思路如下:1.由输入编辑框获得用户输入的Z0、Z L、f和εr;2.在“开始”按钮的callback函数中进行运算,并控制各个axis的显示;3.图形的动态显示由一个while循环实现,并由全局标记变量flag控制;4.在“停止”按钮的callback函数中令flag = 1,while循环跳出。
(三)程序运行效果1.行波演示中端接匹配负载zo = zl = 50Ω2.驻波演示1)终端短路zo = 50Ωzl = 02)终端开路zo = 50Ωzl = inf3)终端接纯电抗负载zo = 50Ωzl = X * j3.行驻波演示(四)主程序代码function varargout = StatusAnaly(varargin)%********************************************************%% Copyright (C), 2009-2012,Lyric %% FileName: StatusAnaly.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% STATUSANALY M-file for StatusAnaly.fig% STATUSANALY, by itself, creates a new STATUSANALY or raises the existing% singleton*.%% H = STATUSANALY returns the handle to a new STATUSANALY or the handle to % the existing singleton*.%% STATUSANALY('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in STATUSANALY.M with the given input arguments. %% STATUSANALY('Property','Value',...) creates a new STATUSANALY or raises the % existing singleton*. Starting from the left, property value pairs are% applied to the GUI before StatusAnaly_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to StatusAnaly_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help StatusAnaly% Last Modified by GUIDE v2.5 11-May-2010 14:30:20% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @StatusAnaly_OpeningFcn, ...'gui_OutputFcn', @StatusAnaly_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before StatusAnaly is made visible.function StatusAnaly_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 StatusAnaly (see VARARGIN)% Choose default command line output for StatusAnalyhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes StatusAnaly wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = StatusAnaly_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 structurevarargout{1} = handles.output;function edit_zo_Callback(hObject, eventdata, handles)% hObject handle to edit_zo (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 edit_zo as text% str2double(get(hObject,'String')) returns contents of edit_zo as a double% --- Executes during object creation, after setting all properties.function edit_zo_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_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');endfunction edit_zl_Callback(hObject, eventdata, handles)% hObject handle to edit_zl (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 edit_zl as text% str2double(get(hObject,'String')) returns contents of edit_zl as a double% --- Executes during object creation, after setting all properties.function edit_zl_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_zl (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 btn_begin.function btn_begin_Callback(hObject, eventdata, handles)% hObject handle to btn_begin (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%获得传输线特性阻抗temp = get(handles.edit_zo, 'string');zo = str2num(temp);%获得传输线负载阻抗temp = get(handles.edit_zl, 'string');zl = str2num(temp);%获得传输介质相对介电常数temp = get(handles.edit_Er, 'string');Er = str2num(temp);%获得传输线上传播的电磁波频率temp = get(handles.edit_f, 'string');f = str2num(temp) * 1000000;w = 2 * pi * f;%获得相波长、相位常数len = GetLen(f, Er);L = 2 * len; %横坐标范围L为两倍的相波长beita = GetBeita(f, Er);z = linspace(0, L, 200);zn = z ./ len; %zn为相对于相波长len归一化的横坐标%获得反射系数[gamal, gama] = GetGama(zo, zl, beita, z);set(handles.edit_gama, 'string', num2str(abs(gamal)));%获得驻波系数rou = GetRou(gamal);set(handles.edit_rou, 'string', num2str(rou));%获得行波系数k = 1 / rou;set(handles.edit_k, 'string', num2str(k));t = 0;Ts = 0.06;fs = 4 * f;%标记变量,当flag = 1 时图像停止,当flag = 0 时图像继续运动global flagflag = 0;while flag == 0%获得传输线输入阻抗Zi = GetZi(zo, gama);%绘制传输线输入阻抗plot(handles.axes_zi, zn, abs(Zi));if max(abs(Zi)) > 500limzL = 0;limzH = 500;elseif (max(abs(Zi)) - min(abs(Zi))) < 1limzL = min(abs(Zi)) - 1;limzH = max(abs(Zi)) + 1;elselimzL = min(abs(Zi));limzH = max(abs(Zi));endaxis(handles.axes_zi, [0, max(zn), limzL, limzH]);title(handles.axes_zi, '输入电阻波形');xlabel(handles.axes_zi, 'z(lamda)');ylabel(handles.axes_zi, 'Zin(ohmic)');%获得传输线输入输出电压[Ui, Uo] = GetUio(beita, gama, z);[Uit, Uot] = GetUiot(Ui, Uo, f, t);%绘制传输线输入输出电压plot(handles.axes_u, zn, Uit, 'b', zn, Uot, 'r');axis(handles.axes_u, [0, max(zn), -1, 1]);title(handles.axes_u, '入射和反射电压波形');xlabel(handles.axes_u, 'z(lamda)');ylabel(handles.axes_u, 'Ui/Uo(V)');legend(handles.axes_u, 'Ui', 'Uo', 2);%获得传输线入射和反射电流[Ii, Io] = GetIio(Ui, zo, gama);%获得传输线合成电压、电流[Is, Us] = GetIUs(Ui, Uo, Ii, Io);[Ist, Ust] = GetIUst(Is, Us, f, t);%绘制传输线合成电压、电流plot(handles.axes_us, zn, Ust);limu = 1 + abs(gamal);axis(handles.axes_us, [0, max(zn), -limu, limu]);title(handles.axes_us, '合成电压波形');xlabel(handles.axes_us, 'z(lamda)');ylabel(handles.axes_us, 'Us(V)');plot(handles.axes_is, zn, Ist);limi = (1 + abs(gamal)) / zo;axis(handles.axes_is, [0, max(zn), -limi, limi]);title(handles.axes_is, '合成电流波形');xlabel(handles.axes_is, 'z(lamda)');ylabel(handles.axes_is, 'Is(A)');%获得并绘制电压相位ph = angle(Us .* exp(1i * 2 * pi * f /fs * t));plot(handles.axes_ph, zn, ph / pi);axis(handles.axes_ph, [0, max(zn), -1.1, 1.1]);title(handles.axes_ph, '合成电压相位波形');xlabel(handles.axes_ph, 'z(lamda)');ylabel(handles.axes_ph, 'thita(pi)');t = t + Ts;pause(Ts);end% --- Executes on button press in btn_stop.function btn_stop_Callback(hObject, eventdata, handles)% hObject handle to btn_stop (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global flagflag = 1;function edit_gama_Callback(hObject, eventdata, handles)% hObject handle to edit_gama (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 edit_gama as text% str2double(get(hObject,'String')) returns contents of edit_gama as a double% --- Executes during object creation, after setting all properties.function edit_gama_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_gama (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');endfunction edit_rou_Callback(hObject, eventdata, handles)% hObject handle to edit_rou (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 edit_rou as text% str2double(get(hObject,'String')) returns contents of edit_rou as a double% --- Executes during object creation, after setting all properties.function edit_rou_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_rou (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');endfunction edit_k_Callback(hObject, eventdata, handles)% hObject handle to edit_k (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 edit_k as text% str2double(get(hObject,'String')) returns contents of edit_k as a double% --- Executes during object creation, after setting all properties.function edit_k_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_k (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');endfunction edit_f_Callback(hObject, eventdata, handles)% hObject handle to edit_f (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 edit_f as text% str2double(get(hObject,'String')) returns contents of edit_f as a double% --- Executes during object creation, after setting all properties.function edit_f_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_f (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');endfunction edit_Er_Callback(hObject, eventdata, handles)% hObject handle to edit_Er (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 edit_Er as text% str2double(get(hObject,'String')) returns contents of edit_Er as a double% --- Executes during object creation, after setting all properties.function edit_Er_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_Er (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 during object creation, after setting all properties.function axes_u_CreateFcn(hObject, eventdata, handles)% hObject handle to axes_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: place code in OpeningFcn to populate axes_u(五)子程序代码(按照在主程序中出现的顺序排列)function Len = GetLen(f, Er)%********************************************************%% Copyright (C), 2009-2012,Lyric %% FileName: GetLen.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetLen% Description: 获得传输线上所传输的电磁波的相波长% Called By: StatusAnaly.m% Input: f 传输线中所传输电磁波的频率% Er 传输线中传输介质的相对介电常数% Return: Len 传输线中所传电磁波的相波长C = 300000000;Len = C / f / sqrt(Er);function Beita = GetBeita(f, Er)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetBeita.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetBeita% Description: get the phase-shift constant 获得相移常数% Called By: StatusAnaly.m% Input: f the freqency of the wave propagated in the medium % Er the relative permittivity of the medium% Return: Beita the phase-shift constant of the wavepi = 3.1415926;%真空中的电磁波速度,单位:m/sC=300000000;%数字角频率W = 2 * pi * f;Beita = W * sqrt(Er) / C;function [GamaL, Gama] = GetGama(zo, zl, beita, z)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetGama.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetGama% Description: get the reflection coefficient 获得反射系数% Called By: StatusAnaly.m% Input: zo the characteristic impedance of the transmission line % zl the load impedance of the transmission line% beita the phase-shift constant of the transmission line% z 相对于相波长归一化的横坐标% Return: GamaL 反射系数的模值% Gama 反射系数的复值if zl == infGamaL = 1;elseGamaL = (zl - zo) / (zl + zo);endGama = abs(GamaL) .* exp(-1i * 2 .* beita .* z);function Rou = GetRou(gamal)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetRou.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetRou% Description: 获得传输线上的驻波系数% Called By: StatusAnaly.m% Input: gamal 传输线上的反射系数% Return: Rou 传输线上的驻波系数Gamal = abs(gamal);Rou = (1 + Gamal) / (1 - Gamal);function Zi = GetZi(zo, gama)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetZi.m % % Author: Lyric % % Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetZi% Description: 获得传输线上各点输入阻抗的复值% Called By: StatusAnaly.m% Input: zo 传输线的特性阻抗% gama 传输线上反射系数的复值% Return: Zi 传输线上各点输入阻抗的复值Zi = zo .* ((1 + gama) ./ (1 - gama));function [Ui, Uo] = GetUio(beita, gama, z)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetUio.m % % Author: Lyric % % Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetUio% Description: 获得输入输出电压的复值% Called By: StatusAnaly.m% Input: beita 传输线上电磁波的相移常数% gama 传输线上电磁波的反射系数% z 相对于相波长归一化的横坐标% Return: Ui 输入电压复值% Uo 输出电压复值% 假定输入电压模值为1U = 1;Ui = U * exp(1i * beita * z);Uo = Ui .* gama;function [Uit, Uot] = GetUiot(Ui, Uo, f, t)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetUiot.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetUiot% Description: 获得输入输出电压瞬时值% Called By: StatusAnaly.m% Input: Ui 输入电压复值% Uo 输出电压复值% f 传输线上所传的电磁波的频率% t 当前时刻% Return: Uit 输入电压瞬时值% Uot 输出电压瞬时值%获得输入输出电压瞬时值fs = 4 * f;Uit = real(Ui .* exp(1i * 2 * pi * f / fs * t));Uot = real(Uo .* exp(1i * 2 * pi * f / fs * t));function [Ii, Io] = GetIio(Ui, zo, gama)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetIio.m %% Author: Lyric % % Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetIio% Description: 获得输入和输出电流的复值% Called By: StatusAnaly.m% Input: Ui 输入电压的复值% zo 传输线特征阻抗% gama 反射系数复值% Return: Ii 输入电流复值% Io 输出电流复值%获得输入输出电流复值Ii = Ui / zo;Io = - Ii .* gama;function [Is, Us] = GetIUs(Ui, Uo, Ii, Io)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetIUs.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetIUs% Description: 获得合成电压电流复值% Called By: StatusAnaly.m% Input: Ui 输入电压复值% Uo 输出电压复值% Ii 输入电流复值% Io 输出电流复值% Return: Is 合成电流复值% Us 合成电压复值%获得合成电压电流复值%I2 = 1;%U2 = Zl * I2;%Us = U2 * cos(beita .* z) + 1i * Zo * I2 * sin(beita .* z);%Is = 1i * U2 /Zo * sin(beita .* z) + I2 * cos(beita .* z);Us = Ui + Uo;Is = Ii + Io;function [Ist, Ust] = GetIUst(Is, Us, f, t)%********************************************************%% Copyright (C), 2009-2012,Lyric %% FileName: GetIUst.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetIUst% Description: 获得合成电压电流瞬时值% Called By: StatusAnaly.m% Input: Is 合成电流复值% Us 合成电压复值% f 电磁波频率% t 当前时间% Return: Ist 合成电流瞬时值% Ust 合成电压瞬时值%获得合成电压电流瞬时值fs = 4 * f;Ust = real(Us .* exp(1i * 2 * pi * f / fs * t));Ist = real(Is .* exp(1i * 2 * pi * f / fs * t));这是在下的大作业,新手编程,颇为拙劣,还望海涵。
(一)主程序变量说明:输入变量:zo 传输线特性阻抗zl 传输线终端负载阻抗Er 传输线介电常数f 传输电磁波的频率由输入变量计算得出的变量:w 传输电磁波的数字角频率len 传输电磁波的相波长beita 相移常数gama 传输线个点反射系数复值gamal 传输线终端反射系数的模rou 驻波系数k 行波系数Zi 传输线各点输入阻抗的复值Ui 传输线各点输入电压的复值Uo 传输线各点输出电压的复值Uit 传输线各点输入电压的瞬时值Uot 传输线各点输出电压的瞬时值Ii 传输线各点输入电流的复值Io 传输线各点输出电流的复值Is 传输线各点合成电流的复值Us 传输线各点合成电压的复值Ist 传输线各点合成电流的瞬时值Ust 传输线各点合成电压的瞬时值ph 传输线各点合成电压的相位(二)主程序流程说明:本程序的界面中共有三个输入编辑框,三个输出编辑框和五个波形显示窗口,分别用来输入:传输线特性阻抗Z0、传输线终端负载阻抗Z L、传输的电磁波的频率f、传输线传输介质的相对介电常数εr;输出:传输线的终端反射系数ΓL、行波系数ρ、驻波系数K;具体的程序思路如下:1.由输入编辑框获得用户输入的Z0、Z L、f和εr;2.在“开始”按钮的callback函数中进行运算,并控制各个axis的显示;3.图形的动态显示由一个while循环实现,并由全局标记变量flag控制;4.在“停止”按钮的callback函数中令flag = 1,while循环跳出。
(三)程序运行效果1.行波演示中端接匹配负载zo = zl = 50Ω2.驻波演示1)终端短路zo = 50Ωzl = 02)终端开路zo = 50Ωzl = inf3)终端接纯电抗负载zo = 50Ωzl = X * j3.行驻波演示(四)主程序代码function varargout = StatusAnaly(varargin)%********************************************************%% Copyright (C), 2009-2012,Lyric %% FileName: StatusAnaly.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% STATUSANALY M-file for StatusAnaly.fig% STATUSANALY, by itself, creates a new STATUSANALY or raises the existing% singleton*.%% H = STATUSANALY returns the handle to a new STATUSANALY or the handle to % the existing singleton*.%% STATUSANALY('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in STATUSANALY.M with the given input arguments. %% STATUSANALY('Property','Value',...) creates a new STATUSANALY or raises the % existing singleton*. Starting from the left, property value pairs are% applied to the GUI before StatusAnaly_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to StatusAnaly_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help StatusAnaly% Last Modified by GUIDE v2.5 11-May-2010 14:30:20% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @StatusAnaly_OpeningFcn, ...'gui_OutputFcn', @StatusAnaly_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []);if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});elsegui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before StatusAnaly is made visible.function StatusAnaly_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 StatusAnaly (see VARARGIN)% Choose default command line output for StatusAnalyhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes StatusAnaly wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = StatusAnaly_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 structurevarargout{1} = handles.output;function edit_zo_Callback(hObject, eventdata, handles)% hObject handle to edit_zo (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 edit_zo as text% str2double(get(hObject,'String')) returns contents of edit_zo as a double% --- Executes during object creation, after setting all properties.function edit_zo_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_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');endfunction edit_zl_Callback(hObject, eventdata, handles)% hObject handle to edit_zl (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 edit_zl as text% str2double(get(hObject,'String')) returns contents of edit_zl as a double% --- Executes during object creation, after setting all properties.function edit_zl_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_zl (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 btn_begin.function btn_begin_Callback(hObject, eventdata, handles)% hObject handle to btn_begin (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)%获得传输线特性阻抗temp = get(handles.edit_zo, 'string');zo = str2num(temp);%获得传输线负载阻抗temp = get(handles.edit_zl, 'string');zl = str2num(temp);%获得传输介质相对介电常数temp = get(handles.edit_Er, 'string');Er = str2num(temp);%获得传输线上传播的电磁波频率temp = get(handles.edit_f, 'string');f = str2num(temp) * 1000000;w = 2 * pi * f;%获得相波长、相位常数len = GetLen(f, Er);L = 2 * len; %横坐标范围L为两倍的相波长beita = GetBeita(f, Er);z = linspace(0, L, 200);zn = z ./ len; %zn为相对于相波长len归一化的横坐标%获得反射系数[gamal, gama] = GetGama(zo, zl, beita, z);set(handles.edit_gama, 'string', num2str(abs(gamal)));%获得驻波系数rou = GetRou(gamal);set(handles.edit_rou, 'string', num2str(rou));%获得行波系数k = 1 / rou;set(handles.edit_k, 'string', num2str(k));t = 0;Ts = 0.06;fs = 4 * f;%标记变量,当flag = 1 时图像停止,当flag = 0 时图像继续运动global flagflag = 0;while flag == 0%获得传输线输入阻抗Zi = GetZi(zo, gama);%绘制传输线输入阻抗plot(handles.axes_zi, zn, abs(Zi));if max(abs(Zi)) > 500limzL = 0;limzH = 500;elseif (max(abs(Zi)) - min(abs(Zi))) < 1limzL = min(abs(Zi)) - 1;limzH = max(abs(Zi)) + 1;elselimzL = min(abs(Zi));limzH = max(abs(Zi));endaxis(handles.axes_zi, [0, max(zn), limzL, limzH]);title(handles.axes_zi, '输入电阻波形');xlabel(handles.axes_zi, 'z(lamda)');ylabel(handles.axes_zi, 'Zin(ohmic)');%获得传输线输入输出电压[Ui, Uo] = GetUio(beita, gama, z);[Uit, Uot] = GetUiot(Ui, Uo, f, t);%绘制传输线输入输出电压plot(handles.axes_u, zn, Uit, 'b', zn, Uot, 'r');axis(handles.axes_u, [0, max(zn), -1, 1]);title(handles.axes_u, '入射和反射电压波形');xlabel(handles.axes_u, 'z(lamda)');ylabel(handles.axes_u, 'Ui/Uo(V)');legend(handles.axes_u, 'Ui', 'Uo', 2);%获得传输线入射和反射电流[Ii, Io] = GetIio(Ui, zo, gama);%获得传输线合成电压、电流[Is, Us] = GetIUs(Ui, Uo, Ii, Io);[Ist, Ust] = GetIUst(Is, Us, f, t);%绘制传输线合成电压、电流plot(handles.axes_us, zn, Ust);limu = 1 + abs(gamal);axis(handles.axes_us, [0, max(zn), -limu, limu]);title(handles.axes_us, '合成电压波形');xlabel(handles.axes_us, 'z(lamda)');ylabel(handles.axes_us, 'Us(V)');plot(handles.axes_is, zn, Ist);limi = (1 + abs(gamal)) / zo;axis(handles.axes_is, [0, max(zn), -limi, limi]);title(handles.axes_is, '合成电流波形');xlabel(handles.axes_is, 'z(lamda)');ylabel(handles.axes_is, 'Is(A)');%获得并绘制电压相位ph = angle(Us .* exp(1i * 2 * pi * f /fs * t));plot(handles.axes_ph, zn, ph / pi);axis(handles.axes_ph, [0, max(zn), -1.1, 1.1]);title(handles.axes_ph, '合成电压相位波形');xlabel(handles.axes_ph, 'z(lamda)');ylabel(handles.axes_ph, 'thita(pi)');t = t + Ts;pause(Ts);end% --- Executes on button press in btn_stop.function btn_stop_Callback(hObject, eventdata, handles)% hObject handle to btn_stop (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global flagflag = 1;function edit_gama_Callback(hObject, eventdata, handles)% hObject handle to edit_gama (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 edit_gama as text% str2double(get(hObject,'String')) returns contents of edit_gama as a double% --- Executes during object creation, after setting all properties.function edit_gama_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_gama (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');endfunction edit_rou_Callback(hObject, eventdata, handles)% hObject handle to edit_rou (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 edit_rou as text% str2double(get(hObject,'String')) returns contents of edit_rou as a double% --- Executes during object creation, after setting all properties.function edit_rou_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_rou (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');endfunction edit_k_Callback(hObject, eventdata, handles)% hObject handle to edit_k (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 edit_k as text% str2double(get(hObject,'String')) returns contents of edit_k as a double% --- Executes during object creation, after setting all properties.function edit_k_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_k (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');endfunction edit_f_Callback(hObject, eventdata, handles)% hObject handle to edit_f (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 edit_f as text% str2double(get(hObject,'String')) returns contents of edit_f as a double% --- Executes during object creation, after setting all properties.function edit_f_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_f (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');endfunction edit_Er_Callback(hObject, eventdata, handles)% hObject handle to edit_Er (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 edit_Er as text% str2double(get(hObject,'String')) returns contents of edit_Er as a double% --- Executes during object creation, after setting all properties.function edit_Er_CreateFcn(hObject, eventdata, handles)% hObject handle to edit_Er (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 during object creation, after setting all properties.function axes_u_CreateFcn(hObject, eventdata, handles)% hObject handle to axes_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: place code in OpeningFcn to populate axes_u(五)子程序代码(按照在主程序中出现的顺序排列)function Len = GetLen(f, Er)%********************************************************%% Copyright (C), 2009-2012,Lyric %% FileName: GetLen.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetLen% Description: 获得传输线上所传输的电磁波的相波长% Called By: StatusAnaly.m% Input: f 传输线中所传输电磁波的频率% Er 传输线中传输介质的相对介电常数% Return: Len 传输线中所传电磁波的相波长C = 300000000;Len = C / f / sqrt(Er);function Beita = GetBeita(f, Er)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetBeita.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetBeita% Description: get the phase-shift constant 获得相移常数% Called By: StatusAnaly.m% Input: f the freqency of the wave propagated in the medium % Er the relative permittivity of the medium% Return: Beita the phase-shift constant of the wavepi = 3.1415926;%真空中的电磁波速度,单位:m/sC=300000000;%数字角频率W = 2 * pi * f;Beita = W * sqrt(Er) / C;function [GamaL, Gama] = GetGama(zo, zl, beita, z)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetGama.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetGama% Description: get the reflection coefficient 获得反射系数% Called By: StatusAnaly.m% Input: zo the characteristic impedance of the transmission line % zl the load impedance of the transmission line% beita the phase-shift constant of the transmission line% z 相对于相波长归一化的横坐标% Return: GamaL 反射系数的模值% Gama 反射系数的复值if zl == infGamaL = 1;elseGamaL = (zl - zo) / (zl + zo);endGama = abs(GamaL) .* exp(-1i * 2 .* beita .* z);function Rou = GetRou(gamal)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetRou.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetRou% Description: 获得传输线上的驻波系数% Called By: StatusAnaly.m% Input: gamal 传输线上的反射系数% Return: Rou 传输线上的驻波系数Gamal = abs(gamal);Rou = (1 + Gamal) / (1 - Gamal);function Zi = GetZi(zo, gama)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetZi.m % % Author: Lyric % % Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetZi% Description: 获得传输线上各点输入阻抗的复值% Called By: StatusAnaly.m% Input: zo 传输线的特性阻抗% gama 传输线上反射系数的复值% Return: Zi 传输线上各点输入阻抗的复值Zi = zo .* ((1 + gama) ./ (1 - gama));function [Ui, Uo] = GetUio(beita, gama, z)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetUio.m % % Author: Lyric % % Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetUio% Description: 获得输入输出电压的复值% Called By: StatusAnaly.m% Input: beita 传输线上电磁波的相移常数% gama 传输线上电磁波的反射系数% z 相对于相波长归一化的横坐标% Return: Ui 输入电压复值% Uo 输出电压复值% 假定输入电压模值为1U = 1;Ui = U * exp(1i * beita * z);Uo = Ui .* gama;function [Uit, Uot] = GetUiot(Ui, Uo, f, t)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetUiot.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetUiot% Description: 获得输入输出电压瞬时值% Called By: StatusAnaly.m% Input: Ui 输入电压复值% Uo 输出电压复值% f 传输线上所传的电磁波的频率% t 当前时刻% Return: Uit 输入电压瞬时值% Uot 输出电压瞬时值%获得输入输出电压瞬时值fs = 4 * f;Uit = real(Ui .* exp(1i * 2 * pi * f / fs * t));Uot = real(Uo .* exp(1i * 2 * pi * f / fs * t));function [Ii, Io] = GetIio(Ui, zo, gama)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetIio.m %% Author: Lyric % % Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetIio% Description: 获得输入和输出电流的复值% Called By: StatusAnaly.m% Input: Ui 输入电压的复值% zo 传输线特征阻抗% gama 反射系数复值% Return: Ii 输入电流复值% Io 输出电流复值%获得输入输出电流复值Ii = Ui / zo;Io = - Ii .* gama;function [Is, Us] = GetIUs(Ui, Uo, Ii, Io)%********************************************************% % Copyright (C), 2009-2012,Lyric %% FileName: GetIUs.m % % Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 % %********************************************************%% Function: GetIUs% Description: 获得合成电压电流复值% Called By: StatusAnaly.m% Input: Ui 输入电压复值% Uo 输出电压复值% Ii 输入电流复值% Io 输出电流复值% Return: Is 合成电流复值% Us 合成电压复值%获得合成电压电流复值%I2 = 1;%U2 = Zl * I2;%Us = U2 * cos(beita .* z) + 1i * Zo * I2 * sin(beita .* z);%Is = 1i * U2 /Zo * sin(beita .* z) + I2 * cos(beita .* z);Us = Ui + Uo;Is = Ii + Io;function [Ist, Ust] = GetIUst(Is, Us, f, t)%********************************************************%% Copyright (C), 2009-2012,Lyric %% FileName: GetIUst.m %% Author: Lyric %% Version: 1.0 %% Date: 2010-05-11 %%********************************************************%% Function: GetIUst% Description: 获得合成电压电流瞬时值% Called By: StatusAnaly.m% Input: Is 合成电流复值% Us 合成电压复值% f 电磁波频率% t 当前时间% Return: Ist 合成电流瞬时值% Ust 合成电压瞬时值%获得合成电压电流瞬时值fs = 4 * f;Ust = real(Us .* exp(1i * 2 * pi * f / fs * t));Ist = real(Is .* exp(1i * 2 * pi * f / fs * t));这是在下的大作业,新手编程,颇为拙劣,还望海涵。