(完整word版)漢寧窗的matlab實現(xiàn)_第1頁
(完整word版)漢寧窗的matlab實現(xiàn)_第2頁
免費預覽已結束,剩余11頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、數(shù)字信號處理課程設計題目:用漢寧窗設計FIR數(shù)字低通濾波器對給定數(shù)據(jù)進行濾波院系:專業(yè): 通信工程班級:學號:姓名:指導教師:職稱:1.1 FIR濾波器:有限長單位脈沖響應數(shù)字濾波器(Finite Impulse ResponseDigital Filter,縮寫FIRDF):有限長單位沖激響應濾波器,是 數(shù)字信號處理系統(tǒng)中最基本的元件,最大優(yōu)點是可以實現(xiàn)線性相 性濾波,它可以在保證任意幅頻特性的同時具有嚴格的線性相頻 特性,同時其單位抽樣響應是有限長的,因而濾波器是穩(wěn)定的系 統(tǒng)。因此,F(xiàn)IR濾波器在通信、圖像處理、模式識別等領域都有 著廣泛的應用。FIR濾波器的設計方法主要分為兩類:第一類是

2、 基于逼近理想濾波器器特性的方法包括窗函數(shù)法、頻率采樣法、和等波紋最佳逼近法;第二類是最優(yōu)設計法。設FIRDF的單位脈沖響應h(n)的長度為N N,則其頻率響應函 數(shù)為N二H (ej)二為 h(n)eTn(1-1)一般將H(ej)表示成如下形式:H(ej)二Hg( )e門)(1-2)式中,Hgj)是的實函數(shù)(可以去負值)。與前面的表示形式,即H (ejK) = H g伸)e曲相比,Hg(co)與國不同。日仲)與伸)不HgCJ為幅頻特性函數(shù),稱*)為相頻特性函數(shù)。同。為了區(qū)別于幅頻響應函數(shù)H(eH(e 切和相頻響應函數(shù):(),稱第一類線性相位FIRDF的相位特性函數(shù)是的嚴格線性函數(shù): - - (

3、1-3)第二類線性相位FIRDF的相位特性函數(shù)如下:-0 - (1-4)式中,是常數(shù),厲是起始相位。入在信號處理中很 有實用價值(如希伯爾特變換器),這是FIRDF除了線性相位濾 波外,還具有真正交變換作用。1.2 窗函數(shù)設計法:窗函數(shù)設計法的基本思想是用FIRDF逼近希望的濾波特性。設希望逼近的濾波器的頻率響應為Hde,其單位脈沖響應用hdn表示。為了設計簡單方便,通常選擇Hdej-為具有片段常數(shù)特性的理想濾波器。因此hdn是無限長非因果序列,不能直接作 為FIRDF的單位脈沖響應。窗函數(shù)設計法就是截取hdn為有限長的一段因果序列,并用合適的窗口函數(shù)進行加權作為FIRDF的單位脈沖響應h n

4、。常見的窗函數(shù),可以分為以下主要類型,(1)冪窗-米用時間變量某種冪次的函數(shù),如矩形、二角 形、梯形或其它時間(t)的高次幕;(2)三角函數(shù)窗-應用三角函數(shù),即正弦或余弦函數(shù)等組合 成復合函數(shù),例如漢寧窗、海明窗等;(3)指數(shù)窗-采用指數(shù)時間函數(shù),例如高斯窗等 其性能如表1-1所示:名稱濾波器過渡帶寬最小阻帶衰減名稱濾波器過渡帶寬最小阻帶衰減矩形1.8n/M21dBPARZENWIN6.6n/M56db巴特利特6.1n/M25dBFLATTOPWIN19.6n/M108db漢寧6.2n/M44dBGAUSSWIN5.8n/M60db漢明6.6n/M51dBBARTHANNWIN3.6n/M40

5、db布萊克曼11n/M 74dBBLACKMANHARRS6.1n/M109dbBOHMANWIIJ5.8n/M51.5dbCHEBWIN15.2n/M113dbNUTTALLWIN15.4n/M 108dbTUKE YWIN2.4n/M22db表1-1常見窗函數(shù)性能表用窗口設計法基本步驟如下:(1)構造希望逼近的頻率響應函數(shù)Hde。以低通線性相位FIRDF設計為例,一般選擇Hder為線性理想低通濾波器,即(2)求出hdn。對Hde進行IFT得到(3)加窗得到FIRDF的單位脈沖響應hn,(1-7)式中,wn稱為窗口函數(shù),其長度為N N。如果要求第一類線性相位FIRDF,貝卩要求h n關于N

6、1 /2點偶對稱。而hdn關于n =.點偶對稱,所,N -1 /2,同時要求w n關于N -1 /2點偶對稱1.3 漢寧窗:漢寧窗(Hanning Window)又稱升余弦窗,漢寧窗可以看作是3個矩形時間窗的頻譜之和,或者說是3個sin t型函數(shù)之和,而括號中的兩項相對于第一個譜窗向左、右各移動了n/T,從而使旁瓣互相抵消,消去高頻干擾和漏能??梢钥?出,漢寧窗主瓣加寬并降低,e%,0c、0,0,叭 H(1-5)Hdejdndncn-?二n_(1-6)H Hde ej旁瓣則顯著減小,從減小泄漏觀點出發(fā),漢寧窗優(yōu)于矩形窗.但漢寧窗主瓣加寬,相當于分析帶寬加寬,頻率分辨力下降。Whng為漢寧窗的幅

7、度響應函數(shù)。二、設計流程圖:本課程設計主要是對一段數(shù)據(jù),加入噪聲后,用漢寧窗函數(shù)法設計出的FIR濾波器對加入噪聲后的數(shù)據(jù)信號進行濾波去噪處 理,并且分析對比前后時域和頻域波形的程序設計。程序的設計流程圖如下圖2-1所示:0 0跡警 WcWc。世(1-8)根據(jù)傅里葉變換的線性性質和調制定理得到W ej = FT WhnnWhnge二N二/2二0.5WRg,0.25WRg-0.25WRgN -1ge_N /2(1-9)當N N 1 1時,N N -1-1 N N,則Whng 叫Fg.嘰2co - IN -1(1-10)開始圖2-1程序設計流程圖三、matlab 設計函數(shù)及結果:用漢寧窗設計的FIR

8、數(shù)字低通濾波器的程序(含界面):function varargout = hanning(varargin)% HANNING M-file for hanning.fig% HANNING, by itself, creates a new HANNING or raises the existing% singleton*.% H = HANNING returns the handle to a new HANNING or the handle to% the existing singleton*.% HANNING(CALLBACK,hObject,eventData,handle

9、s,.) calls the local% function named CALLBACK in HANNING.M with the given input arguments.%HANNING( Property,Value,.) creates a new HANNING or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before hanning_OpeningFunction gets called. An% unrecog

10、nized property name or invalid value makes property application% stop. All inputs are passed to hanning_OpeningFcn via varargin.% *See GUI Options on GUIDEs Tools menu. Choose GUI allows only one % instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the

11、response to help hanning % Last Modified by GUIDE v2.5 29-Jun-201111:03:04% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name,mfilename,.gui_Singleton,gui_Singleton,.gui_OpeningFcn,hanning_OpeningFcn,gui_OutputFcn,hanning_OutputFcn,gui_LayoutFcn, .gui_Callback,);if

12、 nargin & ischar(varargin1)gui_State.gui_Callback = str2func(varargin1); end if nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:); elsegui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before hanning is made visible.function hanning_Opening

13、Fcn(hObject, eventdata, handles, varargin)global xn; global hj1; global hj2;% 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 lin

14、e arguments to hanning (see VARARGIN)hj1=load( E:a.txt );xn=hj1;% Choose default command line output for hanning handles.output = hObject;% Update handles structure guidata(hObject, handles);% UIWAIT makes hanning wait for user response (see UIRESUME)% uiwait(handles.hanning_gui);% - Outputs from th

15、is function are returned to the command line. function varargout =hanning_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (seeVARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handle

16、s and user data (see GUIDATA)% Get default command line output from handles structure varargout1 = handles.output;function edt_wp_Callback(hObject, eventdata, handles)% hObject handle to edt_wp (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handl

17、es and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of edt_wp as text% str2double(get(hObject,String) returns contents of edt_wp as a double% - Executes during object creation, after setting all properties.function edt_wp_CreateFcn(hObject, eventdata, handles)% hObject handle

18、 to edt_wp (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 ),

19、get(0, defaultUicontrolBackgroundColor )set(hObject, BackgroundColor , white);endfunction edt_ws_Callback(hObject, eventdata, handles)% hObject handle to edt_ws (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% H

20、ints: get(hObject,String) returns contents of edt_ws as text% str2double(get(hObject,String) returns contents of edt_ws as a double% - Executes during object creation, after setting all properties.function edt_ws_CreateFcn(hObject, eventdata, handles)% hObject handle to edt_ws (see GCBO)% eventdata

21、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, defaultUicontrolBackground

22、Color )set(hObject, BackgroundColor , white);end% - Executes on button press in btn_creat.function btn_creat_Callback(hObject, eventdata, handles) global xn; global hj1; global hj2;% hObject handle to btn_creat (see GCBO)% eventdata reserved - to be defined in a futureversion of MATLAB % handles str

23、ucture with handles and user data (see GUIDATA)H=findobj( Tag , edt_wp );aaa=get(H, H=findobj( Tag , edt_ws );aaa=get(H, deltaw=ws-wp;N0=ceil(6.2*pi/deltaw);N=N0+mod(N0+1,2);n=0:N-1;wn=0.5*(1-cos(2*pi*n/(N-1);wc=(ws+wp)/2;nn=(N-1)/2;hd=sin(wc*(n-nn)+eps)./(pi*(n-nn)+eps); h=hd.*wn;H,w=freqz(h,1,1000

24、, whole);H=(H(1:1:501);w=(w(1:1:501);mag=abs(H);db=20*log10(mag+eps)/max(mag); pha=angle(H);yn=conv(xn,h);axes(handles.axes1);plot(h);grid;title( 實際單位沖擊響應); axes(handles.axes2);plot(w/pi,db);grid;title(漢寧窗濾波器的幅頻特性);axes(handles.axes3);plot(w/pi,pha);grid;title(漢寧窗濾波器的相頻特性);axes(handles.axes4);plot(xn);grid;title(輸入信號);axes(handles.axes5);plot(yn);grid;title(輸出信號);% - Executes on button press in btn_zero.function btn_zero_Callback(hObject, eventdata, handles)% hObject handle to btn_zero (see GCBO)% eventdata reserved - to be defined in a

溫馨提示

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

評論

0/150

提交評論