1 简介
在本文中,我们分别研究了在MATLAB环境下IIR数字滤波器的典型设计和完全设计等方法。 典型设计是先按一定规则将给出的数字滤波器的技术指标转换成模拟低通滤波器的技术指标,据此产生模拟滤波器原型,然后把模拟低通滤波器原型转换成模拟低通、高通、带通滤波器,最后再把模拟滤波器转换成数字滤波器。 完全设计方法中我们利用函数直接设计出低通、高通、带通滤波器,并分别用巴特沃斯(Butterworth)滤波器来实现语音去噪。
2 部分代码
function varargout = AMtiaozhi(varargin)% AMTIAOZHI M-file for AMtiaozhi.fig% AMTIAOZHI, by itself, creates a new AMTIAOZHI or raises the existing% singleton*.%% H = AMTIAOZHI returns the handle to a new AMTIAOZHI or the handle to% the existing singleton*.%% AMTIAOZHI('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in AMTIAOZHI.M with the given input arguments.%% AMTIAOZHI('Property','Value',...) creates a new AMTIAOZHI or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before AMtiaozhi_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to AMtiaozhi_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 AMtiaozhi% Last Modified by GUIDE v2.5 10-May-2010 16:42:40% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @AMtiaozhi_OpeningFcn, ... 'gui_OutputFcn', @AMtiaozhi_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin & isstr(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before AMtiaozhi is made visible.function AMtiaozhi_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 AMtiaozhi (see VARARGIN)% Choose default command line output for AMtiaozhihandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes AMtiaozhi wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = AMtiaozhi_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;% --- Executes during object creation, after setting all properties.function popupmenu1_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endset(hObject, 'String', {'调制信号', '载波信号','已调波信号'});% --- Executes on selection change in popupmenu1.function popupmenu1_Callback(hObject, eventdata, handles)% hObject handle to popupmenu1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array% contents{get(hObject,'Value')} returns selected item from popupmenu1% --- Executes during object creation, after setting all properties.function popupmenu2_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));endset(hObject, 'String', {'高通滤波', '低通滤波','带通滤波'});% --- Executes on selection change in popupmenu2.function popupmenu2_Callback(hObject, eventdata, handles)% hObject handle to popupmenu2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array% contents{get(hObject,'Value')} returns selected item from popupmenu2% --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)popup_sel_index = get(handles.popupmenu1, 'Value');switch popup_sel_index case 1 dt=0.01; t=0:dt:10;Fs=1/dt; e=sinc(t-5);%调制信号 elength=length(e);%求采样点个数 E=fft(e,elength);%快速傅里叶变换 %fe=-Fs/2:elength:Fs/2; En=fftshift(E);%对fft输出进行重新排列,将零频分量移到频谱中心 axes(handles.axes1); plot(t,e);title('调制信号'); xlabel('时间s'); ylabel('强度值'); axis([0 10 1.1*min(e) 1.1*max(e)]); axes(handles.axes2); plot(abs(En));title('调制信号频谱'); axis([0 1000 1.1*min(abs(En)) 1.1*max(abs(En))]); set(handles.axes2,'Xticklabel',[-50,-30,-10,10,30,50]) xlabel('频率Hz'); ylabel('幅度值'); case 2 dt=0.01; t=0:dt:10;Fs=1/dt; s=cos(60*pi*t)+cos(40*pi*t)+cos(20*pi*t);%载波信号 slength=length(s);%求采样点个数 S=fft(s);%快速傅里叶变换 %fs=linspace(-Fs/2,Fs/2,slength); Sn=fftshift(S); axes(handles.axes3); plot(t,s);title('载波信号'); xlabel('时间s'); ylabel('强度值'); axes(handles.axes4);plot(abs(Sn));title('载波信号频谱'); axis([0 1000 1.1*min(abs(Sn)) 1.1*max(abs(Sn))]); set(handles.axes4,'Xticklabel',[-50,-30,-10,10,30,50]) xlabel('频率Hz'); ylabel('幅度值'); case 3 dt=0.01; t=0:dt:10;Fs=1/dt; s=cos(60*pi*t)+cos(40*pi*t)+cos(20*pi*t);%载波信号 e=sinc(t-5);%调制信号 p=e.*s;%调制 plength=length(p); P=fft(p); %fp=linspace(-Fs/2,Fs/2,plength); Pn=fftshift(P); axes(handles.axes5); plot(t,p);title('调幅信号'); xlabel('时间s'); ylabel('强度值'); axis([0 10 1.1*min(p) 1.1*max(p)]); axes(handles.axes6); plot(abs(Pn));title('调幅信号频谱'); axis([0 1000 1.1*min(abs(Pn)) 1.1*max(abs(Pn))]); set(handles.axes6,'Xticklabel',[-50,-30,-10,10,30,50]) xlabel('频率Hz'); ylabel('幅度值');end% 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)% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)pend% 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)
3 仿真结果
4 参考文献
[1]王蔚. MATLAB环境下的数字滤波器设计及其应用[D]. 苏州大学, 2002.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。