1、学 号: 序 号: 大连海事大学 作 业 设 计 题 目 信号卷积仿真 学 院 信息技术学院 专 业 电科专业 班 级 电科09-4班 姓 名 指导教师 2011 年 6 月 30 日 内容摘要 信号与系统是电类专业必修的一门重要的技术基础课,它具有基础科学和技术科学的二重性,不仅是电类学生学习后续课程的基础,也直接为解决电工电子工程中的一些实际问题服务。大二下学期开始,通过对本课程的学习,我初步掌握了近代信号与系统的一些基本知识和概念,能分析计算一些常见的,
2、比较简单的信号处理,初步具有了解决实际问题的能力,并为后续课程的学习准备了必要的信号理论知识。在这个分析解决问题的过程中需要运用到MATLAB软件。MATLAB是矩阵实验室(Matrix Laboratory)的简称,是美国MathWorks公司出品的商业数学软件,用于算法开发、数据可视化、数据分析以及数值计算的高级技术计算语言和交互式环境,主要包括MATLAB和Simulink两大部分。 我主要是运用matlab模拟离散时间信号的卷积运算。 1 题目分析 1.设计题目 用gui设计出简单的界面,实现的功能为:点击按钮一显示
3、sin函数,点击按钮二显示cos函数波形,点击卷积按钮显示卷积波形。 对于离散时间信号函数做卷积可以直接用内置函数conv ,如果不用内置函数的话可以先求两个函数的傅里叶变换的乘积,然后再求傅里叶逆变换,算是通用办法,此方法可以求连续时间函数的卷积,本次设计为节省时间提高效率,用的是conv函数。 界面内容包括三个按钮一个坐标轴。 实现方法如下: 1、 创建布局 使界面简洁美观,注意对齐方式与间隔。 2、 添加资源修改属性 修改string,字体大小,注意tag的标注,有可能不经意创建了多余的按钮。 3、 保存后打开m文件 2.代码分析 前面大段内容为系统内置不要动。 下
4、面是按钮一的代码 function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:0.001:4*pi; plot(t,sin(t)); end ax
5、es(handles.sin(x)); 实现功能为按钮一控制显示sin函数 下面是按钮二的代码 % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure
6、with handles and user data (see GUIDATA) t=0:0.001:4*pi; plot(t,cos(t)); end axes(handles.cos(x)); 实现功能为按钮二控制显示cos函数 下面是按钮三代码 % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) %
7、eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:0.001:4*pi; a=conv(sin(t),cos(t)); plot(a) axes(handles.conv); 过程中多复制了按钮删掉就好了 实现功能为按钮三控制显示卷积函数 实验结果如下:
8、 附录: 实验完整代码如下 : function varargout = lll(varargin) % LLL M-file for lll.fig % LLL, by itself, creates a new LLL or raises the existing % singleton*. % % H = LLL returns the handle to a ne
9、w LLL or the handle to % the existing singleton*. % % LLL('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in LLL.M with the given input arguments. % % LLL('Property','Value',...) creates a new LLL or raises the % existing singleton*
10、 Starting from the left, property value pairs are % applied to the GUI before lll_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to lll_OpeningFcn via varargin. % % *See GUI Options o
11、n 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 lll % Last Modified by GUIDE v2.5 29-Jun-2011 21:58:21 % Begin initialization code - DO NOT EDIT gui_Sing
12、leton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @lll_OpeningFcn, ... 'gui_OutputFcn', @lll_OutputFcn, ... 'gui_LayoutFcn', [] , ...
13、 'gui_Callback', []); if nargin & isstr(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 %
14、 Executes just before lll is made visible. function lll_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 a
15、nd user data (see GUIDATA) % varargin command line arguments to lll (see VARARGIN) % Choose default command line output for lll handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes lll wait for user response (see UIRESUME) % uiwait(handles.fig
16、ure1); % --- Outputs from this function are returned to the command line. function varargout = lll_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 versio
17、n 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 pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handl
18、e to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:0.001:4*pi; plot(t,sin(t)); end axes(handles.sin(x)); % --- Executes on button press in pushbutton2. function pushbu
19、tton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:0.001:4*pi; plot(t,cos(t)); end axes(handles.cos(x));
20、 % --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) t=0:0.001:4*pi; a=conv(sin(t),cos(t)); plot(a) axes(handles.conv); 9






