实现滤波器的自己设计,功能和自带的fdatoolmatlab源码程序 - matlab通信信号 - 谷速源码
下载频道> 资源分类> matlab源码> 通信信号> 实现滤波器的自己设计,功能和自带的fdatoolmatlab源码程序

标题:实现滤波器的自己设计,功能和自带的fdatoolmatlab源码程序
分享到:

所属分类: 通信信号 资源类型:程序源码 文件大小: 10.46 KB 上传时间: 2019-06-16 22:04:48 下载次数: 77 资源积分:1分 提 供 者: zhangsan456 code
内容:
实现滤波器的自己设计,功能和自带的fdatoolmatlab源码程序
function varargout = lowpass(varargin)
% LOWPASS M-file for lowpass.fig
%      LOWPASS, by itself, creates a new LOWPASS or raises the existing
%      singleton*.
%
%      H = LOWPASS returns the handle to a new LOWPASS or the handle to
%      the existing singleton*.
%
%      LOWPASS('CALLBACK',h ,eventData,handles,...) calls the local
%      function named CALLBACK in LOWPASS.M with the given input arguments.
%
%      LOWPASS('Property','Value',...) creates a new LOWPASS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before lowpass_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to lowpass_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 lowpass
 
% Last Modified by GUIDE v2.5 23-Nov-2006 17:24:09
 
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @lowpass_OpeningFcn, ...
                   'gui_OutputFcn',  @lowpass_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin & isstr(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 lowpass is made visible.
function lowpass_OpeningFcn(h , eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% h    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 lowpass (see VARARGIN)
 
% Choose default command line output for lowpass
handles.output = h ;
 
% Update handles structure
guidata(h , handles);
 
% UIWAIT makes lowpass wait for user response (see UIRESUME)
% uiwait(handles.figure1);
 
 
% --- Outputs from this function are returned to the command line.
function varargout = lowpass_OutputFcn(h , eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% h    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 during creation, after setting all properties.
function Hr_rp_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rp (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rp_Callback(h , eventdata, handles)
% h    handle to Hr_rp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rp as text
%        str2double(get(h ,'String')) returns contents of Hr_rp as a double
 
 
% --- Executes during creation, after setting all properties.
function Hr_rs_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rs (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rs_Callback(h , eventdata, handles)
% h    handle to Hr_rs (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rs as text
%        str2double(get(h ,'String')) returns contents of Hr_rs as a double
 
 
% --- Executes during creation, after setting all properties.
function Hw_wp_CreateFcn(h , eventdata, handles)
% h    handle to Hw_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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hw_wp_Callback(h , eventdata, handles)
% h    handle to Hw_wp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hw_wp as text
%        str2double(get(h ,'String')) returns contents of Hw_wp as a double
 
 
% --- Executes during creation, after setting all properties.
function Hw_ws_CreateFcn(h , eventdata, handles)
% h    handle to Hw_ws (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hw_ws_Callback(h , eventdata, handles)
% h    handle to Hw_ws (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hw_ws as text
%        str2double(get(h ,'String')) returns contents of Hw_ws as a double
 
 
% --- Executes on button press in Hd_design.
function Hd_design_Callback(h , eventdata, handles)
% h    handle to Hd_design (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
 
 fs=str2double(get(handles.Hf_fs,'String'));
rp = str2double(get(handles.Hr_rp,'String'));
rs = str2double(get(handles.Hr_rs,'String'));
ws = str2double(get(handles.Hw_ws,'String'));
wp = str2double(get(handles.Hw_wp,'String'));
as = str2double(get(handles.Hr_rstop1,'String'));
ap = str2double(get(handles.Hr_rpass,'String'));
as2 = str2double(get(handles.Hr_rstop2,'String'));
 
 if  get(handles.radio_fir,'Value')==1
[type]=selecttype(get(handles.Hl_low,'Value'),get(handles.Hh_high,'Value'),get(handles.Hb_bandpass,'Value'),get(handles.Hb_bandstop,'Value'));
[b,a,n]=fir_filter(fs,wp,ws,rp,rs,as,ap,type);
else
    [type]=selecttype(get(handles.Hl_low,'Value'),get(handles.Hh_high,'Value'),get(handles.Hb_bandpass,'Value'),get(handles.Hb_bandstop,'Value'));
 [b,a,n]=iir_filter(fs,wp,ws,rp,rs,as,ap,type,get(handles.popupmenu2,'Value'));
 end
    
[H,W]=freqz(b,a);
handles.metricdata.b = b;
guidata(h ,handles)
handles.metricdata.a = a;
guidata(h ,handles)
 
axes(handles.Ha_axes1);
plot(W/pi,20*log10(abs(H)));grid on;
figure;freqz(b,a);
 
% fvtool(b,a);
% --- Executes during creation, after setting all properties.
function [type]=selecttype(type1,type2,type3,type4)
if type1==1
    type=1;
elseif type2==1
    type=2;
elseif type3==1
    type=3;
else
    type=4;
end
%-----------------------------------------------------------------
function [b,a,n]=fir_filter(fs,wp,ws,rp,rs,as,ap,type)
  N1=abs(ceil(8*pi/(ws/fs-wp/fs)));
    N2=abs(ceil(8*pi/(wp/fs-rp/fs)));
     N3=abs(ceil(8*pi/(wp/fs-ws/fs)));
     N4=abs(ceil(8*pi/(rp/fs-wp/fs)));
    wnl=(ws+wp)/fs/2;
    wnb=(wp+rp)/fs/2;
    wns=(ws+rs)/fs/2;
     a=1;
   
   if type==1
    n=N1; b=fir1(n,wnl);
    elseif type==2
    n=N3;  b=fir1(n,wnl,'high');
    elseif type==3
       n=N2; b=fir1(n,[wnb wns],'bandpass');
    else
       n=N4;  b=fir1(n,[wnb wns],'stop');
    end
%-----------------------------------------------------------------
  function [b,a,n]=iir_filter(fs,wp,ws,rp,rs,as,ap,type,point)
    if type==1
      [b,a,n]=lowfilter(fs,wp,ws,rp,rs,point);
    elseif type==2
        [b,a,n]=highfilter(fs,wp,ws,rp,rs,point);
    elseif type==3
      [b,a,n]=bandpassfilter(fs,wp,ws,rp,rs,as,ap,point);
    else
      [b,a,n]=bandstopfilter(fs,wp,ws,rp,rs,as,ap,point);
    end
 
  
%-----------------------------------------------------------------
function [b,a,n]=lowfilter(fs,wp,ws,rp,rs,point)
lowpass_sel_index = point;
switch lowpass_sel_index
    case 1
     [n,wn]=buttord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=butter(n,wn);
    case 2
       [n,wn]=cheb1ord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=cheby1(n,rp,wn);
    case 3
            [n,wn]=cheb2ord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=cheby2(n,rp,wn);
    case 4
     [n,wn]=ellipord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=ellip(n,rp,rs,wn);
 
end
 
%-----------------------------------------------------------------
   function [b,a,n]=highfilter(fs,wp,ws,rp,rs,point)
lowpass_sel_index = point;
switch lowpass_sel_index
    case 1
     [n,wn]=buttord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=butter(n,wn,'high');
    case 2
       [n,wn]=cheb1ord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=cheby1(n,rp,wn,'high');
    case 3
            [n,wn]=cheb2ord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=cheby2(n,rp,wn,'high');
    case 4
     [n,wn]=ellipord(wp/fs/2,ws/fs/2,rp,rs);
[b,a]=ellip(n,rp,rs,wn,'high');
 
end
 
%-----------------------------------------------------------------
 
function [b,a,n]=bandpassfilter(fs,wp,ws,rp,rs,as,ap,point)
lowpass_sel_index = point;
switch lowpass_sel_index
    case 1
     [n,wn]=buttord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=butter(n,wn);
    case 2
       [n,wn]=cheb1ord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=cheby1(n,ap,wn);
    case 3
            [n,wn]=cheb2ord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=cheby2(n,ap,wn);
    case 4
     [n,wn]=ellipord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=ellip(n,ap,as,wn);
 
end
%-----------------------------------------------------------------
 
function [b,a,n]=bandstopfilter(fs,wp,ws,rp,rs,as,ap,point)
lowpass_sel_index = point;
switch lowpass_sel_index
    case 1
     [n,wn]=buttord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=butter(n,wn,'stop');
    case 2
       [n,wn]=cheb1ord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=cheby1(n,ap,wn,'stop');
    case 3
            [n,wn]=cheb2ord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=cheby2(n,ap,wn,'stop');
    case 4
     [n,wn]=ellipord([wp/fs/2 ws/fs/2],[rp/fs/2,rs/fs/2],ap,as);
[b,a]=ellip(n,ap,as,wn,'stop');
 
end
 
 
 
 
 
 
 
function Hf_fs_CreateFcn(h , eventdata, handles)
% h    handle to Hf_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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hf_fs_Callback(h , eventdata, handles)
% h    handle to Hf_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(h ,'String') returns contents of Hf_fs as text
%        str2double(get(h ,'String')) returns contents of Hf_fs as a double
 fs=str2double(get(handles.Hf_fs,'String'));
 
% --- Executes during creation, after setting all properties.
function Hp_popup_CreateFcn(h , eventdata, handles)
% h    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(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(h ,'string',{'Butterworth','Chebyshev_type1','Chebyshev_type2','Eliptic'});
 
% --- Executes on selection change in popupmenu2.
function Hp_popup_Callback(h , eventdata, handles)
% h    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(h ,'String') returns popupmenu2 contents as cell array
%        contents{get(h ,'Value')} returns selected item from popupmenu2
 
 
% --- Executes on button press in Hl_low.
function Hl_low_Callback(h , eventdata, handles)
% h    handle to Hl_low (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of Hl_low
set(handles.Hl_low, 'Value', 1);
set(handles.Hh_high, 'Value', 0);
set(handles.Hb_bandpass, 'Value', 0);
set(handles.Hb_bandstop, 'Value', 0);
set(handles.Hr_rstop1, 'Visible', 'off');
set(handles.Hr_rpass, 'Visible', 'off');
set(handles.Hr_rstop2, 'Visible', 'off');
set(handles.text23, 'Visible', 'off');
set(handles.text24, 'Visible', 'off');
set(handles.text25, 'Visible', 'off');
set(handles.text5, 'String', 'wp');
set(handles.text6, 'String', 'ws');
set(handles.text3, 'String', 'rp');
set(handles.text4, 'String', 'rs');
 
% --- Executes on button press in Hh_high.
function Hh_high_Callback(h , eventdata, handles)
% h    handle to Hh_high (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of Hh_high
set(handles.Hl_low, 'Value', 0);
set(handles.Hh_high, 'Value', 1);
set(handles.Hb_bandpass, 'Value', 0);
set(handles.Hb_bandstop, 'Value', 0);
set(handles.Hr_rstop1, 'Visible', 'off');
set(handles.Hr_rpass, 'Visible', 'off');
set(handles.Hr_rstop2, 'Visible', 'off');
set(handles.text23, 'Visible', 'off');
set(handles.text24, 'Visible', 'off');
set(handles.text25, 'Visible', 'off');
set(handles.text5, 'String', 'wp');
set(handles.text6, 'String', 'ws');
set(handles.text3, 'String', 'rp');
set(handles.text4, 'String', 'rs');
% --- Executes on button press in Hb_bandpass.
function Hb_bandpass_Callback(h , eventdata, handles)
% h    handle to Hb_bandpass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of Hb_bandpass
 
set(handles.Hl_low, 'Value', 0);
set(handles.Hh_high, 'Value', 0);
set(handles.Hb_bandpass, 'Value', 1);
set(handles.Hb_bandstop, 'Value', 0);
set(handles.text5, 'String', 'Fpass1');
set(handles.text6, 'String', 'Fpass2');
set(handles.text3, 'String', 'Fstop1');
set(handles.text4, 'String', 'Fstop2');
set(handles.Hr_rstop1, 'Visible', 'on');
set(handles.Hr_rpass, 'Visible', 'on');
set(handles.Hr_rstop2, 'Visible', 'on');
set(handles.text23, 'Visible', 'on');
set(handles.text24, 'Visible', 'on');
set(handles.text25, 'Visible', 'on');
set(handles.text23, 'String', 'Rstop1');
set(handles.text24, 'String', 'Rpass');
set(handles.text25, 'String', 'Rstop2');
 
% --- Executes on button press in Hb_bandstop.
function Hb_bandstop_Callback(h , eventdata, handles)
% h    handle to Hb_bandstop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of Hb_bandstop
set(handles.Hl_low, 'Value', 0);
set(handles.Hh_high, 'Value', 0);
set(handles.Hb_bandpass, 'Value', 0);
set(handles.Hb_bandstop, 'Value', 1);
set(handles.text5, 'String', 'Fpass1');
set(handles.text6, 'String', 'Fpass2');
set(handles.text3, 'String', 'Fstop1');
set(handles.text4, 'String', 'Fstop2');
set(handles.text23, 'String', 'Rpass1');
set(handles.text24, 'String', 'Rstop');
set(handles.text25, 'String', 'Rpass2');
set(handles.Hr_rstop1, 'Visible', 'on');
set(handles.Hr_rpass, 'Visible', 'on');
set(handles.Hr_rstop2, 'Visible', 'on');
set(handles.text23, 'Visible', 'on');
set(handles.text24, 'Visible', 'on');
set(handles.text25, 'Visible', 'on');
 
 
 
% --- Executes during creation, after setting all properties.
function Hf_fs1_CreateFcn(h , eventdata, handles)
% h    handle to Hf_fs1 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hf_fs1_Callback(h , eventdata, handles)
% h    handle to Hf_fs1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hf_fs1 as text
%        str2double(get(h ,'String')) returns contents of Hf_fs1 as a double
 
 
% --- Executes during creation, after setting all properties.
function Hp_pass1_CreateFcn(h , eventdata, handles)
% h    handle to Hp_pass1 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hp_pass1_Callback(h , eventdata, handles)
% h    handle to Hp_pass1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hp_pass1 as text
%        str2double(get(h ,'String')) returns contents of Hp_pass1 as a double
 
 
% --- Executes during creation, after setting all properties.
function Hf_fpass2_CreateFcn(h , eventdata, handles)
% h    handle to Hf_fpass2 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hf_fpass2_Callback(h , eventdata, handles)
% h    handle to Hf_fpass2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hf_fpass2 as text
%        str2double(get(h ,'String')) returns contents of Hf_fpass2 as a double
 
 
% --- Executes during creation, after setting all properties.
function Hf_stop_CreateFcn(h , eventdata, handles)
% h    handle to Hf_stop (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hf_stop_Callback(h , eventdata, handles)
% h    handle to Hf_stop (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hf_stop as text
%        str2double(get(h ,'String')) returns contents of Hf_stop as a double
 
 
% --- Executes during creation, after setting all properties.
function Hf_rp1_CreateFcn(h , eventdata, handles)
% h    handle to Hf_rp1 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hf_rp1_Callback(h , eventdata, handles)
% h    handle to Hf_rp1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hf_rp1 as text
%        str2double(get(h ,'String')) returns contents of Hf_rp1 as a double
 
 
% --- Executes during creation, after setting all properties.
function Hr_rp2_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rp2 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rp2_Callback(h , eventdata, handles)
% h    handle to Hr_rp2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rp2 as text
%        str2double(get(h ,'String')) returns contents of Hr_rp2 as a double
 
 
% --- Executes during creation, after setting all properties.
function Hr_rs1_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rs1 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rs1_Callback(h , eventdata, handles)
% h    handle to Hr_rs1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rs1 as text
%        str2double(get(h ,'String')) returns contents of Hr_rs1 as a double
 
 
% --- Executes during creation, after setting all properties.
function popupmenu2_CreateFcn(h , eventdata, handles)
% h    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(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(h , 'String', { 'Butterworth', 'Chebyshev Type1', 'Chebyshev Type2','Ellipic'});
 
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(h , eventdata, handles)
% h    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(h ,'String') returns popupmenu2 contents as cell array
%        contents{get(h ,'Value')} returns selected item from popupmenu2
 
 
% --- Executes during creation, after setting all properties.
function popupmenu3_CreateFcn(h , eventdata, handles)
% h    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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
set(h , 'String', { 'Hamming', 'Hann', 'Kaiser','Triangular','Blackman','Gaussian','Chebyshev'});
 
% --- Executes on selection change in popupmenu3.
function popupmenu3_Callback(h , eventdata, handles)
% h    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)
 
% Hints: contents = get(h ,'String') returns popupmenu3 contents as cell array
%        contents{get(h ,'Value')} returns selected item from popupmenu3
 
 
% --- Executes on button press in radio_sporder.
function radio_sporder_Callback(h , eventdata, handles)
% h    handle to radio_sporder (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.radio_sporder, 'Value', 1);
set(handles.radio_Minorder, 'Value', 0);
% Hint: get(h ,'Value') returns toggle state of radio_sporder
 
 
% --- Executes on button press in Hr_radio16.
function Hr_radio16_Callback(h , eventdata, handles)
% h    handle to Hr_radio16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of Hr_radio16
 
 
% --- Executes during creation, after setting all properties.
function Ho_order_CreateFcn(h , eventdata, handles)
% h    handle to Ho_order (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Ho_order_Callback(h , eventdata, handles)
% h    handle to Ho_order (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Ho_order as text
%        str2double(get(h ,'String')) returns contents of Ho_order as a double
 
 
% --- Executes during creation, after setting all properties.
function Hr_rstop1_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rstop1 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rstop1_Callback(h , eventdata, handles)
% h    handle to Hr_rstop1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rstop1 as text
%        str2double(get(h ,'String')) returns contents of Hr_rstop1 as a double
 
 
% --- Executes during creation, after setting all properties.
function Hr_rpass_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rpass (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rpass_Callback(h , eventdata, handles)
% h    handle to Hr_rpass (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rpass as text
%        str2double(get(h ,'String')) returns contents of Hr_rpass as a double
 
 
% --- Executes during creation, after setting all properties.
function Hr_rstop2_CreateFcn(h , eventdata, handles)
% h    handle to Hr_rstop2 (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
    set(h ,'BackgroundColor','white');
else
    set(h ,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
 
 
function Hr_rstop2_Callback(h , eventdata, handles)
% h    handle to Hr_rstop2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hints: get(h ,'String') returns contents of Hr_rstop2 as text
%        str2double(get(h ,'String')) returns contents of Hr_rstop2 as a double
 
 
% --- Executes on button press in radio_iir.
function radio_iir_Callback(h , eventdata, handles)
% h    handle to radio_iir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of radio_iir
set(handles.radio_iir, 'Value', 1);
set(handles.radio_fir, 'Value', 0);
 
% --- Executes on button press in radio_fir.
function radio_fir_Callback(h , eventdata, handles)
% h    handle to radio_fir (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% Hint: get(h ,'Value') returns toggle state of radio_fir
 
set(handles.radio_iir, 'Value', 0);
set(handles.radio_fir, 'Value', 1);
% --- Executes on button press in Hc_close.
function Hc_close_Callback(h , eventdata, handles)
% h    handle to Hc_close (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 radio_Minorder.
function radio_Minorder_Callback(h , eventdata, handles)
% h    handle to radio_Minorder (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.radio_sporder, 'Value', 0);
set(handles.radio_Minorder, 'Value', 1);
% Hint: get(h ,'Value') returns toggle state of radio_Minorder
 
 
% --- Executes on button press in pushbutton_open.
function pushbutton_open_Callback(h , eventdata, handles)
% h    handle to pushbutton_open (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
[fname,pname]=uigetfile('*.wav');
 [before,FSs,bits]=wavread(fname);
% set(handles.Ho_order, 'String', fname);
handles.metricdata.before = before;
guidata(h ,handles);
handles.metricdata.FSs = FSs;
guidata(h ,handles)
handles.metricdata.bits = bits;
guidata(h ,handles)
 
% set(handles.fs, 'Value', FSs);
% --- Executes on button press in pushbutton_sound.
function pushbutton_sound_Callback(h , eventdata, handles)
% h    handle to pushbutton_sound (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% set(handles.Hf_fs, 'String',FSs);
 if  get(handles.radio_Minorder,'Value')==1
sound(handles.metricdata.before,handles.metricdata.FSs,handles.metricdata.bits);
 else get(handles.radio_Minorder,'Value')==1
     sound(handles.metricdata.after,handles.metricdata.FSs,handles.metricdata.bits);
 end
% --- Executes on button press in pushbutton_show.
function pushbutton_show_Callback(h , eventdata, handles)
% h    handle to pushbutton_show (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
lg=length(handles.metricdata.before);
lgs=[0:lg-1];
befores=fft(handles.metricdata.before);
if get(handles.radio_fir,'Value')==1
    after=fftfilt(handles.metricdata.b,handles.metricdata.before);
else after=filter(handles.metricdata.b,handles.metricdata.a,handles.metricdata.before);
end
afters=fft(after);
figure;subplot(2,2,1);plot(handles.metricdata.before);
subplot(2,2,2);plot(after);
subplot(2,2,3);stem(lgs,befores);
subplot(2,2,4);stem(lgs,afters);
handles.metricdata.after = after;
guidata(h ,handles)
 
% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(h , eventdata, handles)
% h    handle to figure1 (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 pushbutton_filter.
function pushbutton_filter_Callback(h , eventdata, handles)
% h    handle to pushbutton_filter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

文件列表(点击上边下载按钮,如果是垃圾文件请在下面评价差评或者投诉):

lowpass.fig
lowpass.m

关键词: 滤波器

Top_arrow
回到顶部
联系方式| 版权声明| 招聘信息| 广告服务| 银行汇款| 法律顾问| 兼职技术| 付款方式| 关于我们|
网站客服网站客服 程序员兼职招聘 程序员兼职招聘
沪ICP备19040327号-3
公安备案号:沪公网安备 31011802003874号
库纳格流体控制系统(上海)有限公司 版权所有
Copyright © 1999-2014, GUSUCODE.COM, All Rights Reserved