www.gusucode.com > matlab做的可视化界面,实现滤波器的自己设计 > matlab做的可视化界面,实现滤波器的自己设计/lowpass.m
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',hObject,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(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 lowpass (see VARARGIN) % Choose default command line output for lowpass handles.output = hObject; % Update handles structure guidata(hObject, 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(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 during object creation, after setting all properties. function Hr_rp_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rp_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rp as text % str2double(get(hObject,'String')) returns contents of Hr_rp as a double % --- Executes during object creation, after setting all properties. function Hr_rs_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rs_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rs as text % str2double(get(hObject,'String')) returns contents of Hr_rs as a double % --- Executes during object creation, after setting all properties. function Hw_wp_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hw_wp_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hw_wp as text % str2double(get(hObject,'String')) returns contents of Hw_wp as a double % --- Executes during object creation, after setting all properties. function Hw_ws_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hw_ws_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hw_ws as text % str2double(get(hObject,'String')) returns contents of Hw_ws as a double % --- Executes on button press in Hd_design. function Hd_design_Callback(hObject, eventdata, handles) % hObject 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(hObject,handles) handles.metricdata.a = a; guidata(hObject,handles) axes(handles.Ha_axes1); plot(W/pi,20*log10(abs(H)));grid on; figure;freqz(b,a); % fvtool(b,a); % --- Executes during object 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(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hf_fs_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hf_fs as text % str2double(get(hObject,'String')) returns contents of Hf_fs as a double fs=str2double(get(handles.Hf_fs,'String')); % --- Executes during object creation, after setting all properties. function Hp_popup_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')); end set(hObject,'string',{'Butterworth','Chebyshev_type1','Chebyshev_type2','Eliptic'}); % --- Executes on selection change in popupmenu2. function Hp_popup_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 Hl_low. function Hl_low_Callback(hObject, eventdata, handles) % hObject 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(hObject,'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(hObject, eventdata, handles) % hObject 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(hObject,'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(hObject, eventdata, handles) % hObject 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(hObject,'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(hObject, eventdata, handles) % hObject 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(hObject,'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 object creation, after setting all properties. function Hf_fs1_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hf_fs1_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hf_fs1 as text % str2double(get(hObject,'String')) returns contents of Hf_fs1 as a double % --- Executes during object creation, after setting all properties. function Hp_pass1_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hp_pass1_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hp_pass1 as text % str2double(get(hObject,'String')) returns contents of Hp_pass1 as a double % --- Executes during object creation, after setting all properties. function Hf_fpass2_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hf_fpass2_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hf_fpass2 as text % str2double(get(hObject,'String')) returns contents of Hf_fpass2 as a double % --- Executes during object creation, after setting all properties. function Hf_stop_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hf_stop_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hf_stop as text % str2double(get(hObject,'String')) returns contents of Hf_stop as a double % --- Executes during object creation, after setting all properties. function Hf_rp1_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hf_rp1_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hf_rp1 as text % str2double(get(hObject,'String')) returns contents of Hf_rp1 as a double % --- Executes during object creation, after setting all properties. function Hr_rp2_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rp2_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rp2 as text % str2double(get(hObject,'String')) returns contents of Hr_rp2 as a double % --- Executes during object creation, after setting all properties. function Hr_rs1_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rs1_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rs1 as text % str2double(get(hObject,'String')) returns contents of Hr_rs1 as a double % --- 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')); end set(hObject, 'String', { 'Butterworth', 'Chebyshev Type1', 'Chebyshev Type2','Ellipic'}); % --- 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 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 set(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end set(hObject, 'String', { 'Hamming', 'Hann', 'Kaiser','Triangular','Blackman','Gaussian','Chebyshev'}); % --- 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) % Hints: contents = get(hObject,'String') returns popupmenu3 contents as cell array % contents{get(hObject,'Value')} returns selected item from popupmenu3 % --- Executes on button press in radio_sporder. function radio_sporder_Callback(hObject, eventdata, handles) % hObject 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(hObject,'Value') returns toggle state of radio_sporder % --- Executes on button press in Hr_radio16. function Hr_radio16_Callback(hObject, eventdata, handles) % hObject 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(hObject,'Value') returns toggle state of Hr_radio16 % --- Executes during object creation, after setting all properties. function Ho_order_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Ho_order_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Ho_order as text % str2double(get(hObject,'String')) returns contents of Ho_order as a double % --- Executes during object creation, after setting all properties. function Hr_rstop1_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rstop1_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rstop1 as text % str2double(get(hObject,'String')) returns contents of Hr_rstop1 as a double % --- Executes during object creation, after setting all properties. function Hr_rpass_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rpass_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rpass as text % str2double(get(hObject,'String')) returns contents of Hr_rpass as a double % --- Executes during object creation, after setting all properties. function Hr_rstop2_CreateFcn(hObject, eventdata, handles) % hObject 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(hObject,'BackgroundColor','white'); else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); end function Hr_rstop2_Callback(hObject, eventdata, handles) % hObject 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(hObject,'String') returns contents of Hr_rstop2 as text % str2double(get(hObject,'String')) returns contents of Hr_rstop2 as a double % --- Executes on button press in radio_iir. function radio_iir_Callback(hObject, eventdata, handles) % hObject 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(hObject,'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(hObject, eventdata, handles) % hObject 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(hObject,'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(hObject, eventdata, handles) % hObject 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(hObject, eventdata, handles) % hObject 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(hObject,'Value') returns toggle state of radio_Minorder % --- Executes on button press in pushbutton_open. function pushbutton_open_Callback(hObject, eventdata, handles) % hObject 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(hObject,handles); handles.metricdata.FSs = FSs; guidata(hObject,handles) handles.metricdata.bits = bits; guidata(hObject,handles) % set(handles.fs, 'Value', FSs); % --- Executes on button press in pushbutton_sound. function pushbutton_sound_Callback(hObject, eventdata, handles) % hObject 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(hObject, eventdata, handles) % hObject 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(hObject,handles) % --- Executes on mouse press over figure background. function figure1_ButtonDownFcn(hObject, eventdata, handles) % hObject 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(hObject, eventdata, handles) % hObject 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)