基于matlabGUI的IIR低通數(shù)字濾波器設(shè)計_第1頁
基于matlabGUI的IIR低通數(shù)字濾波器設(shè)計_第2頁
基于matlabGUI的IIR低通數(shù)字濾波器設(shè)計_第3頁
基于matlabGUI的IIR低通數(shù)字濾波器設(shè)計_第4頁
基于matlabGUI的IIR低通數(shù)字濾波器設(shè)計_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、DSP課程設(shè)計報告題目基于matlab GUI的IIR低通數(shù)字濾波器設(shè)計 學(xué) 院 信息工程學(xué)院 專 業(yè) 通信工程 姓 名 學(xué) 號 指導(dǎo)教師 完成時間 2015年1月7日 目錄1.設(shè)計的主要內(nèi)容及基本要求12. 總體設(shè)計思路13設(shè)計方案13.1原始語音信號加噪處理13.2濾波器設(shè)計23.2.1數(shù)字濾波器的基本知識23.2.2數(shù)字濾波器的選取33.3濾除噪聲后的語音信號34.GUI設(shè)計44.1 GUI界面設(shè)計概述44.2 GUI界面設(shè)計具體操作44.3GUI界面演示45.課程設(shè)計總結(jié)6參考文獻(xiàn)6附錄71.設(shè)計的主要內(nèi)容及基本要求要求錄制一段自己的語音信號后,對所采集的語音信號加入干擾噪聲,設(shè)計相應(yīng)

2、的數(shù)字濾波器濾除噪聲并進(jìn)行驗證,最后設(shè)計GUI界面。2. 總體設(shè)計思路1.獲取一段語音。2.對所獲取的語音信號進(jìn)行加噪處理。3.設(shè)計數(shù)字濾波器。4.將加噪后的信號通過所設(shè)計的濾波器,濾除噪聲。5.驗證濾除噪聲后的語音信號。6.利用matlab GUI設(shè)計模板設(shè)計相應(yīng)的GUI界面。3設(shè)計方案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濾波器設(shè)計3.2.1數(shù)字濾波器的基本知識數(shù)字濾波器分為FIR數(shù)字濾波器和IIR數(shù)字濾波器兩種,即有限沖激響應(yīng)

4、濾波器(FIR,F(xiàn)inite Impulse Response)濾波器和無線沖激響應(yīng)(IIR,Infinite Impulse Response)濾波器。(一) FIR數(shù)字濾波器 FIR的特點: 不存在極點(z=0除外),系統(tǒng)函數(shù)| z0|處收斂。系統(tǒng)單位沖激響應(yīng)在有限個n值處不為零。結(jié)構(gòu)上主要是非遞歸結(jié)構(gòu),沒有輸出到輸入的反饋。故只能用較高的階數(shù)達(dá)到高的選擇性。FIR數(shù)字濾波器的幅頻特性精度較之于IIR數(shù)字濾波器低,但是線性相位即不同頻率分量的信號經(jīng)過FIR數(shù)字濾波器后他們的時間差不變。FIR數(shù)字濾波器具有系統(tǒng)穩(wěn)定,易實現(xiàn)相位控制,允許設(shè)計多帶通濾波器等優(yōu)點。FIR數(shù)字濾波器的結(jié)構(gòu)有四種:橫

5、截性;級聯(lián)型結(jié)構(gòu);頻率采樣型結(jié)構(gòu);線性相位FIR濾波器的結(jié)構(gòu)(二)IIR數(shù)字濾波器IIR數(shù)字濾波器的特點:電位沖激響應(yīng)h(n)是無限長的;系統(tǒng)函數(shù)H(z)在有限z平面上(0 |z|)有極點存在;結(jié)構(gòu)上存在著輸出到輸入的反饋,也就是結(jié)構(gòu)上是遞歸型的。IIR濾波器運算結(jié)構(gòu)通常由延時、乘以系數(shù)和相加等基本運算組成。有限階IIR的表達(dá)式: IIR數(shù)字濾波器的結(jié)構(gòu)也有四種:直接I型;直接II型典范型;級聯(lián)型;并聯(lián)型。3.2.2數(shù)字濾波器的選取由原始語音信號的頻譜圖可以看出,語音信號的能量集中在低頻部分,所以根據(jù)濾波器的特性和功能,所選擇的濾波器應(yīng)該具有濾除無用的高頻成分的作用,所以可以選用低通濾波器。又

6、由于IIR數(shù)字濾波器的輸出不但取決于過去和現(xiàn)在的輸入,還取決于過去的輸出,所以,選擇IIR數(shù)字濾波器比選擇FIR數(shù)字濾波器要好。所設(shè)計的IIR切比雪夫數(shù)字低通濾波器如下: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濾除噪聲后的語音信號將加噪后的語音信號通過所設(shè)計的低通數(shù)字

7、濾波器:r=filter(Bz,Az,x);并播放語音,聽其效果。由濾除噪聲后的語音信號的頻譜圖可以看出,噪音已被濾除,試聽可知,原始語音信號基本沒有丟失。4.GUI設(shè)計4.1 GUI界面設(shè)計概述GUI設(shè)計面板是GUI設(shè)計工具應(yīng)用的平面,面板上部提供了菜單和常用工具按鈕,左邊提供了多種如命令按鈕、單選按鈕、可編輯文本框、靜態(tài)文本框、彈出式菜單等。進(jìn)行設(shè)計時, 首先單擊面板左邊所需的控件, 然后在右邊的圖形界面編輯區(qū)中再次單擊某一恰當(dāng)位置, 這時將在該位上為圖形界面添加相應(yīng)的控件。一個圖形界面的完成, 除了設(shè)計其外觀外, 還有相當(dāng)?shù)囊徊糠质峭ㄟ^屬性的設(shè)來完成的。應(yīng)用MATLAB制作這樣一個過程是

8、非常方便的, 我們可以通過GUI操作來看到。該環(huán)境下要設(shè)計一個界面友好的仿真軟件,一般應(yīng)完成以下兩個步驟:(1)GUI界面設(shè)計。主要是通過不同的文本框、按鈕等許多工具的使用,設(shè)計出一個圖形用戶界面。要清楚這個圖形界面的功能是什么,即在圖形界面上的操作會引發(fā)什么樣的結(jié)果。(2)回調(diào)函數(shù)的設(shè)計。用戶應(yīng)根據(jù)設(shè)計好的圖形界面的功能,針對各個不同的圖形對象來編寫出能夠?qū)崿F(xiàn)該功能的函數(shù)代碼,確保這個圖形界面能夠完成所預(yù)定的功能。4.2 GUI界面設(shè)計具體操作在matlab命令行窗口中輸入guide或點擊matlab界面上面的菜單中的圖標(biāo),打開gui設(shè)計的圖形界面。然后拖入所要的圖形控件,按需要修改外觀和空

9、間屬性,直至滿足要求。設(shè)置屬性點擊guide界面上方的Run按鈕,會生成一個fig文件,一個m文件,其中fig文件就是界面的圖形,m文件是界面的回調(diào)函數(shù),在m文件里每個控件的回調(diào)函數(shù)都已經(jīng)自動生成,控件要做的工作就是在文件框架下定義某些特殊要求的狀態(tài)并補(bǔ)充完整回調(diào)函數(shù)場, 使單擊控件時激活回調(diào)程序完成一定的功能。4.3GUI界面演示1.初始界面2.輸入相應(yīng)參數(shù)并點擊相應(yīng)控件后界面5.課程設(shè)計總結(jié)這次的課程設(shè)計,讓我對數(shù)字信號處理有了更深的認(rèn)識,對Matlab能更熟練地應(yīng)用,對matlab GUI有了更多的了解。對于GUI在數(shù)字信號處理中的應(yīng)用中,數(shù)字信號處理這門學(xué)科的知識是基礎(chǔ),要掌握數(shù)字信號

10、處理的相關(guān)知識的原理后,并用代碼來實現(xiàn),才能很好地結(jié)合MATLAB進(jìn)行GUI編程。參考文獻(xiàn)1陳后金數(shù)字信號處理第二版北京:高等教育出版社,2008.112劉衛(wèi)國MATLAB程序設(shè)計與應(yīng)用第二版北京:高等教育出版社,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 setting all properties.function edit5_CreateFcn(hObject, eventdata, handles)% hObject

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論