基于matlabGUI的IIR低通数字滤波器设计

上传人:奇*** 文档编号:227408692 上传时间:2023-08-11 格式:DOCX 页数:15 大小:176.50KB
收藏 版权申诉 举报 下载
基于matlabGUI的IIR低通数字滤波器设计_第1页
第1页 / 共15页
基于matlabGUI的IIR低通数字滤波器设计_第2页
第2页 / 共15页
基于matlabGUI的IIR低通数字滤波器设计_第3页
第3页 / 共15页
资源描述:

《基于matlabGUI的IIR低通数字滤波器设计》由会员分享,可在线阅读,更多相关《基于matlabGUI的IIR低通数字滤波器设计(15页珍藏版)》请在装配图网上搜索。

1、DSP课程设计报告题目基于matlab GUI的IIR低通数字滤波器设计 学 院 信息工程学院 专 业 通信工程 姓 名 学 号 指导教师 完成时间 2015年1月7日 目录1.设计的主要内容及基本要求12. 总体设计思路13设计方案13.1原始语音信号加噪处理13.2滤波器设计23.2.1数字滤波器的基本知识23.2.2数字滤波器的选取33.3滤除噪声后的语音信号34.GUI设计44.1 GUI界面设计概述44.2 GUI界面设计具体操作44.3GUI界面演示45.课程设计总结6参考文献6附录71.设计的主要内容及基本要求要求录制一段自己的语音信号后,对所采集的语音信号加入干扰噪声,设计相应

2、的数字滤波器滤除噪声并进行验证,最后设计GUI界面。2. 总体设计思路1.获取一段语音。2.对所获取的语音信号进行加噪处理。3.设计数字滤波器。4.将加噪后的信号通过所设计的滤波器,滤除噪声。5.验证滤除噪声后的语音信号。6.利用matlab GUI设计模板设计相应的GUI界面。3设计方案3.1原始语音信号加噪处理fs=44100; Au=1;s=audioread(C:UsersASUSDesktopyinpin.wav);sound(s,44100);t=(0:length(s)-1)/fs;f=linspace(-fs/2,fs/2,length(s);n=(Au*cos(2*pi*20

3、000*t);x=s+n;sound(x,44100);y1=fft(s);y2=fft(x);y3=fftshift(y1);y4=fftshift(y2);subplot(221);plot(t,s);title(原语音信号);subplot(222);plot(t,x);title(加噪后的语音信号);subplot(223);plot(f,abs(y3);title(原始语音信号频谱);subplot(224);plot(f,abs(y4);title(加噪后的信号频谱);3.2滤波器设计3.2.1数字滤波器的基本知识数字滤波器分为FIR数字滤波器和IIR数字滤波器两种,即有限冲激响应

4、滤波器(FIR,Finite Impulse Response)滤波器和无线冲激响应(IIR,Infinite Impulse Response)滤波器。(一) FIR数字滤波器 FIR的特点: 不存在极点(z=0除外),系统函数| z0|处收敛。系统单位冲激响应在有限个n值处不为零。结构上主要是非递归结构,没有输出到输入的反馈。故只能用较高的阶数达到高的选择性。FIR数字滤波器的幅频特性精度较之于IIR数字滤波器低,但是线性相位即不同频率分量的信号经过FIR数字滤波器后他们的时间差不变。FIR数字滤波器具有系统稳定,易实现相位控制,允许设计多带通滤波器等优点。FIR数字滤波器的结构有四种:横

5、截性;级联型结构;频率采样型结构;线性相位FIR滤波器的结构(二)IIR数字滤波器IIR数字滤波器的特点:电位冲激响应h(n)是无限长的;系统函数H(z)在有限z平面上(0 |z|)有极点存在;结构上存在着输出到输入的反馈,也就是结构上是递归型的。IIR滤波器运算结构通常由延时、乘以系数和相加等基本运算组成。有限阶IIR的表达式: IIR数字滤波器的结构也有四种:直接I型;直接II型典范型;级联型;并联型。3.2.2数字滤波器的选取由原始语音信号的频谱图可以看出,语音信号的能量集中在低频部分,所以根据滤波器的特性和功能,所选择的滤波器应该具有滤除无用的高频成分的作用,所以可以选用低通滤波器。又

6、由于IIR数字滤波器的输出不但取决于过去和现在的输入,还取决于过去的输出,所以,选择IIR数字滤波器比选择FIR数字滤波器要好。所设计的IIR切比雪夫数字低通滤波器如下:T=1;Fs=1/T;Ap=1;As=10;Wp=0.55*pi/T;Ws=0.6*pi/T;wp=(2/T)*tan(Wp/2);ws=(2/T)*tan(Ws/2);N,wc=cheb1ord(wp,ws,Ap,As,s);B,A=cheby1(N,Ap,wc,s);Bz,Az=bilinear(B,A,Fs);H,W=freqz(Bz,Az,512,fs);3.3滤除噪声后的语音信号将加噪后的语音信号通过所设计的低通数字

7、滤波器:r=filter(Bz,Az,x);并播放语音,听其效果。由滤除噪声后的语音信号的频谱图可以看出,噪音已被滤除,试听可知,原始语音信号基本没有丢失。4.GUI设计4.1 GUI界面设计概述GUI设计面板是GUI设计工具应用的平面,面板上部提供了菜单和常用工具按钮,左边提供了多种如命令按钮、单选按钮、可编辑文本框、静态文本框、弹出式菜单等。进行设计时, 首先单击面板左边所需的控件, 然后在右边的图形界面编辑区中再次单击某一恰当位置, 这时将在该位上为图形界面添加相应的控件。一个图形界面的完成, 除了设计其外观外, 还有相当的一部分是通过属性的设来完成的。应用MATLAB制作这样一个过程是

8、非常方便的, 我们可以通过GUI操作来看到。该环境下要设计一个界面友好的仿真软件,一般应完成以下两个步骤:(1)GUI界面设计。主要是通过不同的文本框、按钮等许多工具的使用,设计出一个图形用户界面。要清楚这个图形界面的功能是什么,即在图形界面上的操作会引发什么样的结果。(2)回调函数的设计。用户应根据设计好的图形界面的功能,针对各个不同的图形对象来编写出能够实现该功能的函数代码,确保这个图形界面能够完成所预定的功能。4.2 GUI界面设计具体操作在matlab命令行窗口中输入guide或点击matlab界面上面的菜单中的图标,打开gui设计的图形界面。然后拖入所要的图形控件,按需要修改外观和空

9、间属性,直至满足要求。设置属性点击guide界面上方的Run按钮,会生成一个fig文件,一个m文件,其中fig文件就是界面的图形,m文件是界面的回调函数,在m文件里每个控件的回调函数都已经自动生成,控件要做的工作就是在文件框架下定义某些特殊要求的状态并补充完整回调函数场, 使单击控件时激活回调程序完成一定的功能。4.3GUI界面演示1.初始界面2.输入相应参数并点击相应控件后界面5.课程设计总结这次的课程设计,让我对数字信号处理有了更深的认识,对Matlab能更熟练地应用,对matlab GUI有了更多的了解。对于GUI在数字信号处理中的应用中,数字信号处理这门学科的知识是基础,要掌握数字信号

10、处理的相关知识的原理后,并用代码来实现,才能很好地结合MATLAB进行GUI编程。参考文献1陈后金数字信号处理第二版北京:高等教育出版社,2008.112刘卫国MATLAB程序设计与应用第二版北京:高等教育出版社,2006.7附录%GUI源程序function varargout = gui_lmj(varargin)% GUI_LMJ MATLAB code for gui_lmj.fig% GUI_LMJ, by itself, creates a new GUI_LMJ or raises the existing% singleton*.% H = GUI_LMJ returns th

11、e handle to a new GUI_LMJ or the handle to% the existing singleton*.% GUI_LMJ(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in GUI_LMJ.M with the given input arguments.% GUI_LMJ(Property,Value,.) creates a new GUI_LMJ or raises the% existing singleton*. Starting from

12、 the left, property value pairs are% applied to the GUI before gui_lmj_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to gui_lmj_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only on

13、e% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help gui_lmj% Last Modified by GUIDE v2.5 07-Jan-2015 10:29:29% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, . gui_Singleton, gui_S

14、ingleton, . gui_OpeningFcn, gui_lmj_OpeningFcn, . gui_OutputFcn, gui_lmj_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargi

15、n:);end% End initialization code - DO NOT EDIT% - Executes just before gui_lmj is made visible.function gui_lmj_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 MAT

16、LAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to gui_lmj (see VARARGIN)% Choose default command line output for gui_lmjhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes gui_lmj wait for user response (see UI

17、RESUME)% uiwait(handles.figure1);% - Outputs from this function are returned to the command line.function varargout = gui_lmj_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a fu

18、ture version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;% - Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1

19、(see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global fs;global s;sound(s,fs);% - Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4

20、 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global s;global t;global Au;global f1;global fs;n=(Au*cos(2*pi*f1*t);x=s+n;sound(x,fs);% - Executes on button press in pushbutton5.function pushbutton5_Callback(hO

21、bject, 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)%fs=44100;%s=audioread(C:UsersASUSDesktopyinpin.wav);%t=(0:length(s)-1)/fs;global Au;global fs;global s;gl

22、obal t;global f1;n=(Au*cos(2*pi*f1*t);x=s+n;T=1;Fs=1/T;Ap=1;As=10;Wp=0.55*pi/T;Ws=0.6*pi/T;wp=(2/T)*tan(Wp/2);ws=(2/T)*tan(Ws/2);N,wc=cheb1ord(wp,ws,Ap,As,s);B,A=cheby1(N,Ap,wc,s);Bz,Az=bilinear(B,A,Fs);H,W=freqz(Bz,Az,512,fs);r=filter(Bz,Az,x);sound(r,44100);% - Executes on button press in pushbutt

23、on6.function pushbutton6_Callback(hObject, eventdata, handles)% hObject handle to pushbutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)close% - Executes on button press in pushbutton7.function pushbutton7_

24、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)global s;global t;global f;y1=fft(s);axes(position,0.05 0.6 0.2 0.25);plot(t,s);y2=fftshift(y1)

25、;axes(position,0.05 0.2 0.2 0.25);plot(f,abs(y2);% - Executes on button press in pushbutton8.function pushbutton8_Callback(hObject, eventdata, handles)% hObject handle to pushbutton8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user

26、 data (see GUIDATA)global s;global t;global f;global Au;global n;global f1;x=s+n;y1=fft(x);axes(position,0.3 0.6 0.2 0.25);plot(t,x);y2=fftshift(y1);axes(position,0.3 0.2 0.2 0.25);plot(f,abs(y2);% - Executes on button press in pushbutton9.function pushbutton9_Callback(hObject, eventdata, handles)%

27、hObject handle to pushbutton9 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global fs;global s;global t;global f;global n;x=s+n;T=1;Fs=1/T;Ap=1;As=10;Wp=0.55*pi/T;Ws=0.6*pi/T;wp=(2/T)*tan(Wp/2);ws=(2/T)*tan(Ws/

28、2);N,wc=cheb1ord(wp,ws,Ap,As,s);B,A=cheby1(N,Ap,wc,s);Bz,Az=bilinear(B,A,Fs);H,W=freqz(Bz,Az,512,fs);r=filter(Bz,Az,x);axes(position,0.55 0.6 0.2 0.25);plot(t,r);rc=fftshift(fft(r);axes(position,0.55 0.2 0.2 0.25);plot(f,abs(rc);% - Executes on button press in pushbutton10.function pushbutton10_Call

29、back(hObject, eventdata, handles)% 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)file,path=uigetfile(*.wav);filepath=path,file; global s;s=audioread(filepath);global fs;fs=44100;g

30、lobal t;t=(0:length(s)-1)/fs;global f;f=linspace(-fs/2,fs/2,length(s);function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hOb

31、ject,String) returns contents of edit1 as text% str2double(get(hObject,String) returns contents of edit1 as a doubleglobal Au; Au=str2double(get(handles.edit1,String);guidata(hObject, handles);% - Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventda

32、ta, handles)% hObject handle to edit1 (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(hObj

33、ect,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data

34、(see GUIDATA)% Hints: get(hObject,String) returns contents of edit2 as text% str2double(get(hObject,String) returns contents of edit2 as a doubleglobal f1; global n;global Au; global t;global fs; global s;f1=str2double(get(handles.edit2,String);t=(0:length(s)-1)/fs;n=(Au*cos(2*pi*f1*t);guidata(hObje

35、ct, handles);% - Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns c

36、alled% 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 pushbutton11.function pushbutton11_Callback(hObje

37、ct, eventdata, handles)% hObject handle to pushbutton11 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global fs;T=1;Fs=1/T;Ap=1;As=10;Wp=0.55*pi/T;Ws=0.6*pi/T;wp=(2/T)*tan(Wp/2);ws=(2/T)*tan(Ws/2);N,wc=cheb1ord

38、(wp,ws,Ap,As,s);B,A=cheby1(N,Ap,wc,s);Bz,Az=bilinear(B,A,Fs);H,W=freqz(Bz,Az,512,fs);axes(position,0.8 0.2 0.15 0.25);plot(W,abs(H);function edit5_Callback(hObject, eventdata, handles)% hObject handle to edit5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles stru

39、cture with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit5 as text% str2double(get(hObject,String) returns contents of edit5 as a doubleglobal Wp; Wp=str2double(get(handles.edit5,String);guidata(hObject, handles);% - Executes during object creation, after se

40、tting all properties.function edit5_CreateFcn(hObject, eventdata, handles)% hObject handle to edit5 (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

41、 on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction edit6_Callback(hObject, eventdata, handles)% hObject handle to edit6 (see GCBO)% eventdata reserved - to be defined in a future ve

42、rsion of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edit6 as text% str2double(get(hObject,String) returns contents of edit6 as a doubleglobal Ws; Ws=str2double(get(handles.edit6,String);guidata(hObject, handles);% - Executes dur

43、ing object creation, after setting all properties.function edit6_CreateFcn(hObject, eventdata, handles)% hObject handle to edit6 (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);end13

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!