【毕业设计】78-基于MATLAB的IIR数字滤波器设计与仿真(详细说明书+PPT+原理图+matlab仿真+源代码)

【毕业设计】78-基于MATLAB的IIR数字滤波器设计与仿真(详细说明书+PPT+原理图+matlab仿真+源代码)

摘要

数字滤波器在数字信号处理系统中,通过使用离散系统的特性对系统的信号进行处理,从而改变信号的波形。通过滤波的方式使需要通过的信号通过,杂波或者不需要通过的信息抑制。数字滤波器在应用过程中通常使用做筛选的作用。在实际应用中,可以用作工业零件的筛选、音频信号的过滤。通过去除工业零件的粉尘或者过滤信号的杂波从而获取到最优质的零件或者音频信号的目的。
在本文研究了在环境MATLAB环境下通过对无限脉冲响应(IIR)数字滤波器进行研究与设计,将其进行应用,对数字滤波器进行模拟,数字转化。通过使用脉冲响应不变法对数字滤波器进行设计,在设计过程中模拟实际的环境并且通过调节数字滤波器相关的参数从而实现滤波器的功能。并且详细的说明了数字滤波器的设计步骤以及仿真原理。通过GUI的方式展现数据仿真结果。
本次设计的数字滤波器,在实际的设计上使用到了较少的存储单元,并且运行效率高,处理精度高的优点,保留了传统模拟滤波器的优良品质,所以在实际应用中可以推广在多个不同的行业中,如数据压缩、图像处理等,使用数字滤波器在各行各业中均可以实现其功能。

【关键词】数字滤波器;IIR;信号处理;图像处理

资料包含:
1、详细说明书 1.8W字以上,重复率低
2、答辩PPT
3、MATLAB仿真工程、源代码
4、仿真截图、仿真录屏
5、开题报告
6、任务书
7、中期检查情况表
8、英文文献及翻译

注意:资料为虚拟产品,资料仅用于学习单片机技术及原理。禁止用于他用。

目录

目 录

1 绪论 1
1.1 课题研究背景 1
1.2 数字滤波器应用现状 1
1.3 数字滤波器发展趋势 2
1.4 本文主要研究内容 3
2 数字滤波器基本原理 4
2.1 数字滤波器的功能及意义 4
2.1.1 数字滤波器的分类 5
2.1.2 数字滤波器的设计原则 6
2.2 IIR数字滤波器基本原理及设计方法 7
2.3.1 IIR数字滤波器基本原理 7
2.3.2 IIR数字滤波器设计方法 7
2.3.3 模拟滤波器设计 8
2.3.4 模拟滤波器转化为数字滤波器 12
2.3 本章小结 17
3 基于Matlab的数字滤波器设计方法 18
3.1 Matlab中的数字滤波器设计函数 18
3.3 基于Matlab的IIR数字滤波器仿真分析 20
3.3.1 IIR数字滤波器设计步骤 20
3.3.2 IIR数字滤波器仿真设计 20
3.4 本章小结 24
4 基于Matlab的数字滤波器仿真应用分析 25
4.1 基于GUIDE的滤波系统设计 25
4.2 数字滤波系统的仿真实现 26
4.3 本章小结 30
5 总结与展望 31
致 谢 32
参考文献 33
附 录 A 源代码 35

图片

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

function varargout = myIIR(varargin)
% MYIIR MATLAB code for myIIR.fig
%      MYIIR, by itself, creates a new MYIIR or raises the existing
%      singleton*.
%
%      H = MYIIR returns the handle to a new MYIIR or the handle to
%      the existing singleton*.
%
%      MYIIR('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in MYIIR.M with the given input arguments.
%
%      MYIIR('Property','Value',...) creates a new MYIIR or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before myIIR_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to myIIR_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 myIIR
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @myIIR_OpeningFcn, ...
                   'gui_OutputFcn',  @myIIR_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(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
% --- Executes just before myIIR is made visible.
function myIIR_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 myIIR (see VARARGIN)

% Choose default command line output for myIIR
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes myIIR wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = myIIR_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 structure
varargout{1} = handles.output;
% --- 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 = cellstr(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 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function signal_Callback(hObject, eventdata, handles)
% hObject    handle to signal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of signal as text
%        str2double(get(hObject,'String')) returns contents of signal as a double
% --- Executes during object creation, after setting all properties.
function signal_CreateFcn(hObject, eventdata, handles)
% hObject    handle to signal (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');
end
function Fs_Callback(hObject, eventdata, handles)
% hObject    handle to Fs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Fs as text
%        str2double(get(hObject,'String')) returns contents of Fs as a double
% --- Executes during object creation, after setting all properties.
function Fs_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Fs (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');
end
function N_Callback(hObject, eventdata, handles)
% hObject    handle to N (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of N as text
%        str2double(get(hObject,'String')) returns contents of N as a double
% --- Executes during object creation, after setting all properties.
function N_CreateFcn(hObject, eventdata, handles)
% hObject    handle to N (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');
end
% --- 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 = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
switch(get(handles.popupmenu3,'Value'))
    case 2
        set(handles.in1,'String','通带截止频率');
        set(handles.in2,'String','阻带起始频率');
        set(handles.in3,'String','③');
        set(handles.in4,'String','④');
    case 3
        set(handles.in1,'String','阻带截止频率');
        set(handles.in2,'String','通带起始频率');
        set(handles.in3,'String','③');
        set(handles.in4,'String','④');
    case 4
        set(handles.in1,'String','低端阻带截止频率');
        set(handles.in2,'String','低端通带起始频率');
        set(handles.in3,'String','高端通带截止频率');
        set(handles.in4,'String','高端阻带起始频率');
    case 5
        set(handles.in1,'String','低端通带截止频率');
        set(handles.in2,'String','低端阻带起始频率');
        set(handles.in3,'String','高端阻带截止频率');
        set(handles.in4,'String','高端通带起始频率');
end
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu3 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu3
% --- Executes during object creation, after setting all properties.
function popupmenu3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu3 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu4 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu4
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu4 (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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end
function Ap_Callback(hObject, eventdata, handles)
% hObject    handle to Ap (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Ap as text
%        str2double(get(hObject,'String')) returns contents of Ap as a double
% --- Executes during object creation, after setting all properties.
function Ap_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Ap (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');
end
function As_Callback(hObject, eventdata, handles)
% hObject    handle to As (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of As as text
%        str2double(get(hObject,'String')) returns contents of As as a double
% --- Executes during object creation, after setting all properties.
function As_CreateFcn(hObject, eventdata, handles)
% hObject    handle to As (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');
end
function w1_Callback(hObject, eventdata, handles)
% hObject    handle to w1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of w1 as text
%        str2double(get(hObject,'String')) returns contents of w1 as a double
% --- Executes during object creation, after setting all properties.
function w1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w1 (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');
end
function w2_Callback(hObject, eventdata, handles)
% hObject    handle to w2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of w2 as text
%        str2double(get(hObject,'String')) returns contents of w2 as a double
% --- Executes during object creation, after setting all properties.
function w2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w2 (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');
end
function in1_Callback(hObject, eventdata, handles)
% hObject    handle to in1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of in1 as text
%        str2double(get(hObject,'String')) returns contents of in1 as a double
% --- Executes during object creation, after setting all properties.
function in1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to in1 (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');
end
function in2_Callback(hObject, eventdata, handles)
% hObject    handle to in2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of in2 as text
%        str2double(get(hObject,'String')) returns contents of in2 as a double
% --- Executes during object creation, after setting all properties.
function in2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to in2 (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');
end
function w3_Callback(hObject, eventdata, handles)
% hObject    handle to w3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of w3 as text
%        str2double(get(hObject,'String')) returns contents of w3 as a double
% --- Executes during object creation, after setting all properties.
function w3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w3 (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');
end
function w4_Callback(hObject, eventdata, handles)
% hObject    handle to w4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of w4 as text
%        str2double(get(hObject,'String')) returns contents of w4 as a double
% --- Executes during object creation, after setting all properties.
function w4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to w4 (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');
end
function in3_Callback(hObject, eventdata, handles)
% hObject    handle to in3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of in3 as text
%        str2double(get(hObject,'String')) returns contents of in3 as a double
% --- Executes during object creation, after setting all properties.
function in3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to in3 (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');
end
function in4_Callback(hObject, eventdata, handles)
% hObject    handle to in4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of in4 as text
%        str2double(get(hObject,'String')) returns contents of in4 as a double
% --- Executes during object creation, after setting all properties.
function in4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to in4 (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');
end
% --- 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 with handles and user data (see GUIDATA)
global H w Bz Az
T=1;
%--- 首先判断数字滤波器的设计方法
switch(get(handles.popupmenu4,'Value'))
    case 2  %脉冲响应不变法
        %--- 再判断滤波器的类型
        switch(get(handles.popupmenu1,'Value'))
            case 2  %巴特沃斯滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                    case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=butter(N,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=butter(N,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s');
                        [B,A]=butter(N,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端通带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端阻带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端阻带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端通带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s');
                        [B,A]=butter(N,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕               
            case 3  %切比雪夫I型滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                    case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby1(N,Ap,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby1(N,Ap,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby1(N,Ap,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby1(N,Ap,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕                
            case 4  %切比雪夫II型滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                    case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby2(N,As,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby2(N,As,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby2(N,As,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby2(N,As,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕                
            case 5  %椭圆型滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                   case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=ellip(N,Ap,As,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=wp/T;
                        Ws=ws/T;  %将数字指标转化为模拟指标
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=ellip(N,Ap,As,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s');
                        [B,A]=ellip(N,Ap,As,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp=[wp1 wp2]/T;
                        Ws=[ws1 ws2]/T;
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s');
                        [B,A]=ellip(N,Ap,As,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=impinvar(B,A,1/T);  %用脉冲响应不变法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕                
        end  %滤波器类型判断完毕        
    case 3  %双线性变换法
         %--- 再判断滤波器的类型
        switch(get(handles.popupmenu1,'Value'))
            case 2  %巴特沃斯滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                    case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=butter(N,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=butter(N,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s');
                        [B,A]=butter(N,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端通带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端阻带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端阻带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端通带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=buttord(Wp,Ws,Ap,As,'s');
                        [B,A]=butter(N,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕               
            case 3  %切比雪夫I型滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                    case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby1(N,Ap,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby1(N,Ap,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby1(N,Ap,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=cheb1ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby1(N,Ap,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕                
            case 4  %切比雪夫II型滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                    case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby2(N,As,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=cheby2(N,As,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby2(N,As,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=cheb2ord(Wp,Ws,Ap,As,'s');
                        [B,A]=cheby2(N,As,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕                
            case 5  %椭圆型滤波器
                %--- 再判断滤波器性质:LPF/HPF/BPF/BSF
                switch(get(handles.popupmenu3,'Value'))
                   case 2  %LPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp=str2double(get(handles.w1,'String'));
                        ws=str2double(get(handles.w2,'String'));
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=ellip(N,Ap,As,wc,'s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                    case 3  %HPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws=str2double(get(handles.w1,'String'));   %阻带截止频率
                        wp=str2double(get(handles.w2,'String'));   %通带起始频率
                        Wp=2*tan(wp/2);
                        Ws=2*tan(ws/2);  %将数字指标转化为模拟指标
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s'); %计算相应的模拟滤波器阶数N和3dB截止频率
                        [B,A]=ellip(N,Ap,As,wc,'high','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 4  %BPF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        ws1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        wp1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        wp2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        ws2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s');
                        [B,A]=ellip(N,Ap,As,wc,'bandpass','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                    case 5  %BSF
                        Ap=str2double(get(handles.Ap,'String'));
                        As=str2double(get(handles.As,'String'));
                        wp1=str2double(get(handles.w1,'String'));  %低端阻带截止频率
                        ws1=str2double(get(handles.w2,'String'));  %低端通带起始频率
                        ws2=str2double(get(handles.w3,'String'));  %高端通带截止频率
                        wp2=str2double(get(handles.w4,'String'));  %高端阻带起始频率
                        Wp1=2*tan(wp1/2);
                        Wp2=2*tan(wp2/2);
                        Ws1=2*tan(ws1/2);
                        Ws2=2*tan(ws2/2);
                        Wp=[Wp1 Wp2];
                        Ws=[Ws1 Ws2];
                        [N,wc]=ellipord(Wp,Ws,Ap,As,'s');
                        [B,A]=ellip(N,Ap,As,wc,'stop','s');   %计算相应的模拟滤波器系统函数
                        [Bz,Az]=bilinear(B,A,1/T);  %用双线性变换法将模拟滤波器转换成数字滤波器
                        [H,w]=freqz(Bz,Az);
                        H=H/(H(1));
                end   %滤波器性质判断完毕                
        end  %滤波器类型判断完毕
    otherwise
        clear w H
end
axes(handles.axes1);
plot(w/pi,abs(H),'m');
xlabel('归一化频率w(×πrad/s)');
ylabel('幅值');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global H w
axes(handles.axes2);
plot(w/pi,angle(H),'r');
xlabel('归一化频率w(×πrad/s)');
ylabel('相位');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global S_amp S_pha Fs N s t
Fs=str2double(get(handles.Fs,'String'));
N=str2double(get(handles.N,'String'));
t=0:1/Fs:(N-1)/Fs;
s=eval(get(handles.signal,'String'));
axes(handles.axes3);
plot(t,s,'m');
xlabel('t(s)');
ylabel('幅值');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;
%计算滤波前信号的幅频特性
S_amp=abs(fft(s,length(s))/(length(s)/2));   %幅值
S_pha=angle(fft(s,length(s))/(length(s)/2));  %相位
% --- 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)
global S_amp Fs N
f=(0:N-1)*Fs/N;
axes(handles.axes5);
plot(f,S_amp,'m');
xlabel('f(Hz)');
ylabel('幅值');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;
% --- Executes on button press in pushbutton6.
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)
global S_pha Fs N
f=(0:N-1)*Fs/N;
axes(handles.axes7);
plot(f,S_pha,'m');
xlabel('f(Hz)');
ylabel('相位');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;
% --- Executes on button press in pushbutton7.
function pushbutton7_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 t s Bz Az Sf_amp Sf_pha
sf=filter(Bz,Az,s);
axes(handles.axes4);
plot(t,sf,'r');
xlabel('t(s)');
ylabel('幅值');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;
%计算滤波前信号的幅频特性
Sf_amp=abs(fft(sf,length(sf))/(length(sf)/2));   %幅值
Sf_pha=angle(fft(sf,length(sf))/(length(sf)/2));  %相位
% --- 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 data (see GUIDATA)
global Sf_amp Fs N
f=(0:N-1)*Fs/N;

% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% 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 Sf_pha Fs N
f=(0:N-1)*Fs/N;
axes(handles.axes8);
plot(f,Sf_pha,'r');
xlabel('f(Hz)');
ylabel('相位');
set(gca,'FontSize',8,'Fontname', '楷体');
grid on;
axis tight;


评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cqtianxingkeji

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值