Anda di halaman 1dari 22

FILTER IMPLEMENTATION function varargout = Filter_Implementation(varargin) % FILTER_IMPLEMENTATION M-file for Filter_Implementation.

fig % FILTER_IMPLEMENTATION, by itself, creates a new FILTER_IMPLEMENTATION or raises the existing % singleton*. % % H = FILTER_IMPLEMENTATION returns the handle to a new FILTER_IMPLEMENTATION or the handle to % the existing singleton*. % % FILTER_IMPLEMENTATION('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in FILTER_IMPLEMENTATION.M with the given input arguments. % % FILTER_IMPLEMENTATION('Property','Value',...) creates a new FILTER_IMPLEMENTATION or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before DSP_filter_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Filter_Implementation_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 % Copyright 2002-2003 The MathWorks, Inc. % Edit the above text to modify the response to help Filter_Implementation % Last Modified by GUIDE v2.5 05-Dec-2010 09:01:47 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Filter_Implementation_OpeningFcn, ... 'gui_OutputFcn', @Filter_Implementation_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 Filter_Implementation is made visible.

function Filter_Implementation_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 Filter_Implementation (see VARARGIN) % Choose default command line output for Filter_Implementation handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes Filter_Implementation wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = Filter_Implementation_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 button press in pb1. function pb1_Callback(hObject, eventdata, handles) % hObject handle to pb1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

function edit1_Callback(hObject, eventdata, handles) % hObject handle to edit1 (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 edit1 as text % str2double(get(hObject,'String')) returns contents of edit1 as a double % --- Executes during object creation, after setting all properties. function edit1_CreateFcn(hObject, eventdata, handles) % hObject handle to edit1 (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 edit2_Callback(hObject, eventdata, handles) % hObject handle to edit2 (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 edit2 as text % str2double(get(hObject,'String')) returns contents of edit2 as a double % --- Executes during object creation, after setting all properties. function edit2_CreateFcn(hObject, eventdata, handles) % hObject handle to edit2 (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 edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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 edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double % --- Executes during object creation, after setting all properties. function edit3_CreateFcn(hObject, eventdata, handles) % hObject handle to edit3 (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 edit4_Callback(hObject, eventdata, handles) % hObject handle to edit4 (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 edit4 as text % str2double(get(hObject,'String')) returns contents of edit4 as a double % --- Executes during object creation, after setting all properties. function edit4_CreateFcn(hObject, eventdata, handles) % hObject handle to edit4 (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 edit5_Callback(hObject, eventdata, handles) % hObject handle to edit5 (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 edit5 as text % str2double(get(hObject,'String')) returns contents of edit5 as a double % --- Executes during object creation, after setting all properties. function edit5_CreateFcn(hObject, eventdata, handles) % hObject handle to edit5 (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 pop1. function pop1_Callback(hObject, eventdata, handles) % hObject handle to pop1 (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 pop1 contents as cell array % contents{get(hObject,'Value')} returns selected item from pop1

% --- Executes during object creation, after setting all properties. function pop1_CreateFcn(hObject, eventdata, handles) % hObject handle to pop1 (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 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) % --- 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) % --- Executes on selection change in pop2. function pop2_Callback(hObject, eventdata, handles) % hObject handle to pop2 (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 pop2 contents as cell array % contents{get(hObject,'Value')} returns selected item from pop2 % --- Executes during object creation, after setting all properties. function pop2_CreateFcn(hObject, eventdata, handles) % hObject handle to pop2 (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 button press in pb2. function pb2_Callback(hObject, eventdata, handles) % hObject handle to pb2 (see GCBO)

% eventdata % handles

reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA)

% --- Executes on button press in pb3. function pb3_Callback(hObject, eventdata, handles) % hObject handle to pb3 (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 pb4. function pb4_Callback(hObject, eventdata, handles) % hObject handle to pb4 (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 pb5. function pb5_Callback(hObject, eventdata, handles) % hObject handle to pb5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % -------------------------------------------------------------------function Untitled_1_Callback(hObject, eventdata, handles) % hObject handle to Untitled_1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

function edit6_Callback(hObject, eventdata, handles) % hObject handle to edit6 (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 edit6 as text % str2double(get(hObject,'String')) returns contents of edit6 as a double % --- Executes during object creation, after setting all properties. function edit6_CreateFcn(hObject, eventdata, handles) % hObject handle to edit6 (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 edit7_Callback(hObject, eventdata, handles) % hObject handle to edit7 (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 edit7 as text % str2double(get(hObject,'String')) returns contents of edit7 as a double % --- Executes during object creation, after setting all properties. function edit7_CreateFcn(hObject, eventdata, handles) % hObject handle to edit7 (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 edit8_Callback(hObject, eventdata, handles) % hObject handle to edit8 (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 edit8 as text % str2double(get(hObject,'String')) returns contents of edit8 as a double % --- Executes during object creation, after setting all properties. function edit8_CreateFcn(hObject, eventdata, handles) % hObject handle to edit8 (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 edit9_Callback(hObject, eventdata, handles) % hObject handle to edit9 (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 edit9 as text

% double

str2double(get(hObject,'String')) returns contents of edit9 as a

% --- Executes during object creation, after setting all properties. function edit9_CreateFcn(hObject, eventdata, handles) % hObject handle to edit9 (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 edit10_Callback(hObject, eventdata, handles) % hObject handle to edit10 (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 edit10 as text % str2double(get(hObject,'String')) returns contents of edit10 as a double % --- Executes during object creation, after setting all properties. function edit10_CreateFcn(hObject, eventdata, handles) % hObject handle to edit10 (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 edit11_Callback(hObject, eventdata, handles) % hObject handle to edit11 (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 edit11 as text % str2double(get(hObject,'String')) returns contents of edit11 as a double % --- Executes during object creation, after setting all properties. function edit11_CreateFcn(hObject, eventdata, handles) % hObject handle to edit11 (see GCBO)

% eventdata % handles

reserved - to be defined in a future version of MATLAB 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 edit12_Callback(hObject, eventdata, handles) % hObject handle to edit12 (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 edit12 as text % str2double(get(hObject,'String')) returns contents of edit12 as a double % --- Executes during object creation, after setting all properties. function edit12_CreateFcn(hObject, eventdata, handles) % hObject handle to edit12 (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 Untitled_4_Callback(hObject, eventdata, handles) % hObject handle to Untitled_4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes during object creation, after setting all properties. function uipanel2_CreateFcn(hObject, eventdata, handles) % hObject handle to uipanel2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called

IMP.M h=findobj(gcf,'tag','edit1'); o=str2num(get(h,'string')); h=findobj(gcf,'tag','edit2'); fc1=str2num(get(h,'string'));

h=findobj(gcf,'tag','edit3'); fc2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit4'); fs=str2num(get(h,'string')); h=findobj(gcf,'tag','edit5'); r=str2num(get(h,'string')); h=findobj(gcf,'tag','pop1'); D=get(h,'value'); h=findobj(gcf,'tag','pop2'); E=get(h,'value'); h=findobj(gcf,'tag','edit6'); pf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit7'); pf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit8'); pf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit9'); sf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit10'); sf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit11'); sf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit12'); sf4=str2num(get(h,'string')); wn=fc1/(fs/2); apf1=pf1/(fs/2)*pi; apf2=pf2/(fs/2)*pi; apf3=pf3/(fs/2)*pi; asf1=sf1/(fs/2)*pi; asf2=sf2/(fs/2)*pi; asf3=sf3/(fs/2)*pi; asf4=sf4/(fs/2)*pi; [x,y]=pol2cart(apf1,1);a1=x+y*i; [x,y]=pol2cart(apf2,1);a2=x+y*i; [x,y]=pol2cart(apf3,1);a3=x+y*i; [x,y]=pol2cart(-apf1,1);a4=x+y*i; [x,y]=pol2cart(-apf2,1);a5=x+y*i; [x,y]=pol2cart(-apf3,1);a6=x+y*i; [x,y]=pol2cart(asf1,1);b1=x+y*i; [x,y]=pol2cart(asf2,1);b2=x+y*i; [x,y]=pol2cart(asf3,1);b3=x+y*i; [x,y]=pol2cart(asf4,1);b4=x+y*i; [x,y]=pol2cart(-asf1,1);b5=x+y*i; [x,y]=pol2cart(-asf2,1);b6=x+y*i; [x,y]=pol2cart(-asf3,1);b7=x+y*i; [x,y]=pol2cart(-asf4,1);b8=x+y*i; wn=fc1/(fs/2); if (wn>0)&(wn<1) if D==2 & E==2 wn=fc1/(fs/2); b=fir1(o,wn); filt1=filter(b,1,rec); figure ('Name','Impulse Response','NumberTitle', 'off'); impz(b,1) elseif D==2 & E==3 wn=fc1/(fs/2); b=fir1(o,wn,'high');

filt1=filter(b,1,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,1) elseif D==2 & E==4 wn=fc1/(fs/2); b=fir1(o,wn,'band'); filt1=filter(b,1,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,1) elseif D==2 & E==5 wn=fc1/(fs/2); b=fir1(o,wn,'stop'); filt1=filter(b,1,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,1) elseif D==3 & E==2 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', plot(rec); impz(b,a) elseif D==3 & E==3 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,a) elseif D==3 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=cheby1(o,r,w,'bandpass'); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,a) elseif D==3 & E==5 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'stop'); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,a) elseif D==4 & E==2 wn=fc1/(fs/2); [b,a]=butter(o,wn); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,a) elseif D==4 & E==3 wn=fc1/(fs/2); [b,a]=butter(o,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', impz(b,a) elseif D==4 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2);

'off');

'off');

'off');

'off');

'off');

'off');

'off');

'off');

'off');

w=[wn w2]; [b,a]=butter(o,w,'band'); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', 'off'); impz(b,a) elseif D==4 & E==5 wn=fc1/(fs/2); [b,a]=butter(o,w,'stop'); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', 'off'); impz(b,a) else a=poly([a1 a2 a3 a4 a5 a6]); b=poly([b1 b2 b3 b4 b5 b6 b7 b8]); filt1=filter(b,a,rec); figure ('Name','Impulse Response','NumberTitle', 'off'); impz(b,a) end else disp('error!'); end MAGNI.M h=findobj(gcf,'tag','edit1'); o=str2num(get(h,'string')); h=findobj(gcf,'tag','edit2'); fc1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit3'); fc2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit4'); fs=str2num(get(h,'string')); h=findobj(gcf,'tag','edit5'); r=str2num(get(h,'string')); h=findobj(gcf,'tag','pop1'); D=get(h,'value'); h=findobj(gcf,'tag','pop2'); E=get(h,'value'); h=findobj(gcf,'tag','edit6'); pf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit7'); pf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit8'); pf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit9'); sf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit10'); sf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit11'); sf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit12'); sf4=str2num(get(h,'string')); wn=fc1/(fs/2); apf1=pf1/(fs/2)*pi; apf2=pf2/(fs/2)*pi; apf3=pf3/(fs/2)*pi; asf1=sf1/(fs/2)*pi; asf2=sf2/(fs/2)*pi;

asf3=sf3/(fs/2)*pi; asf4=sf4/(fs/2)*pi; [x,y]=pol2cart(apf1,1);a1=x+y*i; [x,y]=pol2cart(apf2,1);a2=x+y*i; [x,y]=pol2cart(apf3,1);a3=x+y*i; [x,y]=pol2cart(-apf1,1);a4=x+y*i; [x,y]=pol2cart(-apf2,1);a5=x+y*i; [x,y]=pol2cart(-apf3,1);a6=x+y*i; [x,y]=pol2cart(asf1,1);b1=x+y*i; [x,y]=pol2cart(asf2,1);b2=x+y*i; [x,y]=pol2cart(asf3,1);b3=x+y*i; [x,y]=pol2cart(asf4,1);b4=x+y*i; [x,y]=pol2cart(-asf1,1);b5=x+y*i; [x,y]=pol2cart(-asf2,1);b6=x+y*i; [x,y]=pol2cart(-asf3,1);b7=x+y*i; [x,y]=pol2cart(-asf4,1);b8=x+y*i; wn=fc1/(fs/2); if (wn>0)&(wn<1) if D==2 & E==2 wn=fc1/(fs/2); b=fir1(o,wn); filt1=filter(b,1,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,1) elseif D==2 & E==3 wn=fc1/(fs/2); b=fir1(o,wn,'high'); filt1=filter(b,1,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,1) elseif D==2 & E==4 wn=fc1/(fs/2); b=fir1(o,wn,'band'); filt1=filter(b,1,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,1) elseif D==2 & E==5 wn=fc1/(fs/2); b=fir1(o,wn,'stop'); filt1=filter(b,1,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,1) elseif D==3 & E==2 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', plot(rec); freqz(b,a) elseif D==3 & E==3 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) elseif D==3 & E==4 wn=fc1/(fs/2);

'off');

'off');

'off');

'off');

'off');

'off');

w2=fc2/(fs/2); w=[wn w2]; [b,a]=cheby1(o,r,w,'bandpass'); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) elseif D==3 & E==5 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'stop'); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) elseif D==4 & E==2 wn=fc1/(fs/2); [b,a]=butter(o,wn); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) elseif D==4 & E==3 wn=fc1/(fs/2); [b,a]=butter(o,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) elseif D==4 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=butter(o,w,'band'); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) elseif D==4 & E==5 wn=fc1/(fs/2); [b,a]=butter(o,w,'stop'); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) else a=poly([a1 a2 a3 a4 a5 a6]); b=poly([b1 b2 b3 b4 b5 b6 b7 b8]); filt1=filter(b,a,rec); figure ('Name','Magnitude Response','NumberTitle', freqz(b,a) end else disp('error!'); end PLAYFILTER.M h=findobj(gcf,'tag','edit1'); o=str2num(get(h,'string')); h=findobj(gcf,'tag','edit2'); fc1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit3'); fc2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit4');

'off');

'off');

'off');

'off');

'off');

'off');

'off');

fs=str2num(get(h,'string')); h=findobj(gcf,'tag','edit5'); r=str2num(get(h,'string')); h=findobj(gcf,'tag','pop1'); D=get(h,'value'); h=findobj(gcf,'tag','pop2'); E=get(h,'value'); h=findobj(gcf,'tag','edit6'); pf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit7'); pf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit8'); pf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit9'); sf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit10'); sf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit11'); sf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit12'); sf4=str2num(get(h,'string')); wn=fc1/(fs/2); apf1=pf1/(fs/2)*pi; apf2=pf2/(fs/2)*pi; apf3=pf3/(fs/2)*pi; asf1=sf1/(fs/2)*pi; asf2=sf2/(fs/2)*pi; asf3=sf3/(fs/2)*pi; asf4=sf4/(fs/2)*pi; [x,y]=pol2cart(apf1,1);a1=x+y*i; [x,y]=pol2cart(apf2,1);a2=x+y*i; [x,y]=pol2cart(apf3,1);a3=x+y*i; [x,y]=pol2cart(-apf1,1);a4=x+y*i; [x,y]=pol2cart(-apf2,1);a5=x+y*i; [x,y]=pol2cart(-apf3,1);a6=x+y*i; [x,y]=pol2cart(asf1,1);b1=x+y*i; [x,y]=pol2cart(asf2,1);b2=x+y*i; [x,y]=pol2cart(asf3,1);b3=x+y*i; [x,y]=pol2cart(asf4,1);b4=x+y*i; [x,y]=pol2cart(-asf1,1);b5=x+y*i; [x,y]=pol2cart(-asf2,1);b6=x+y*i; [x,y]=pol2cart(-asf3,1);b7=x+y*i; [x,y]=pol2cart(-asf4,1);b8=x+y*i; wn=fc1/(fs/2); if (wn>0)&(wn<1) if D==2 & E==2 wn=fc1/(fs/2); b=fir1(o,wn); filt1=filter(b,1,rec); wavplay(filt1) elseif D==2 & E==3 wn=fc1/(fs/2); b=fir1(o,wn,'high'); filt1=filter(b,1,rec); wavplay(filt1) elseif D==2 & E==4 wn=fc1/(fs/2);

b=fir1(o,wn,'band'); filt1=filter(b,1,rec); wavplay(filt1) elseif D==2 & E==5 wn=fc1/(fs/2); b=fir1(o,wn,'stop'); filt1=filter(b,1,rec); wavplay(filt1) elseif D==3 & E==2 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn); filt1=filter(b,a,rec); wavplay(filt1) elseif D==3 & E==3 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'high'); filt1=filter(b,a,rec); wavplay(filt1) elseif D==3 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=cheby1(o,r,w,'bandpass'); filt1=filter(b,a,rec); wavplay(filt1) elseif D==3 & E==5 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'stop'); filt1=filter(b,a,rec); wavplay(filt1) elseif D==4 & E==2 wn=fc1/(fs/2); [b,a]=butter(o,wn); filt1=filter(b,a,rec); wavplay(filt1) elseif D==4 & E==3 wn=fc1/(fs/2); [b,a]=butter(o,wn,'high'); filt1=filter(b,a,rec); wavplay(filt1) elseif D==4 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=butter(o,w,'band'); filt1=filter(b,a,rec); wavplay(filt1) elseif D==4 & E==5 wn=fc1/(fs/2); [b,a]=butter(o,w,'stop'); filt1=filter(b,a,rec); wavplay(filt1) else a=poly([a1 a2 a3 a4 a5 a6]); b=poly([b1 b2 b3 b4 b5 b6 b7 b8]); filt1=filter(b,a,rec); wavplay(filt1)

end else disp('error!'); end PLAYRECORD.M wavplay(rec) PO_ZE.M h=findobj(gcf,'tag','edit1'); o=str2num(get(h,'string')); h=findobj(gcf,'tag','edit2'); fc1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit3'); fc2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit4'); fs=str2num(get(h,'string')); h=findobj(gcf,'tag','edit5'); r=str2num(get(h,'string')); h=findobj(gcf,'tag','pop1'); D=get(h,'value'); h=findobj(gcf,'tag','pop2'); E=get(h,'value'); h=findobj(gcf,'tag','edit6'); pf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit7'); pf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit8'); pf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit9'); sf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit10'); sf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit11'); sf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit12'); sf4=str2num(get(h,'string')); wn=fc1/(fs/2); apf1=pf1/(fs/2)*pi; apf2=pf2/(fs/2)*pi; apf3=pf3/(fs/2)*pi; asf1=sf1/(fs/2)*pi; asf2=sf2/(fs/2)*pi; asf3=sf3/(fs/2)*pi; asf4=sf4/(fs/2)*pi; [x,y]=pol2cart(apf1,1);a1=x+y*i; [x,y]=pol2cart(apf2,1);a2=x+y*i; [x,y]=pol2cart(apf3,1);a3=x+y*i; [x,y]=pol2cart(-apf1,1);a4=x+y*i; [x,y]=pol2cart(-apf2,1);a5=x+y*i; [x,y]=pol2cart(-apf3,1);a6=x+y*i; [x,y]=pol2cart(asf1,1);b1=x+y*i; [x,y]=pol2cart(asf2,1);b2=x+y*i; [x,y]=pol2cart(asf3,1);b3=x+y*i; [x,y]=pol2cart(asf4,1);b4=x+y*i; [x,y]=pol2cart(-asf1,1);b5=x+y*i; [x,y]=pol2cart(-asf2,1);b6=x+y*i;

[x,y]=pol2cart(-asf3,1);b7=x+y*i; [x,y]=pol2cart(-asf4,1);b8=x+y*i; wn=fc1/(fs/2); if (wn>0)&(wn<1) if D==2 & E==2 wn=fc1/(fs/2); b=fir1(o,wn); filt1=filter(b,1,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,1) elseif D==2 & E==3 wn=fc1/(fs/2); b=fir1(o,wn,'high'); filt1=filter(b,1,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,1) elseif D==2 & E==4 wn=fc1/(fs/2); b=fir1(o,wn,'band'); filt1=filter(b,1,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,1) elseif D==2 & E==5 wn=fc1/(fs/2); b=fir1(o,wn,'stop'); filt1=filter(b,1,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,1) elseif D==3 & E==2 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', plot(rec); zplane(b,a) elseif D==3 & E==3 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) elseif D==3 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=cheby1(o,r,w,'bandpass'); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) elseif D==3 & E==5 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'stop'); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) elseif D==4 & E==2 wn=fc1/(fs/2);

'off');

'off');

'off');

'off');

'off');

'off');

'off');

'off');

[b,a]=butter(o,wn); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) elseif D==4 & E==3 wn=fc1/(fs/2); [b,a]=butter(o,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) elseif D==4 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=butter(o,w,'band'); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) elseif D==4 & E==5 wn=fc1/(fs/2); [b,a]=butter(o,w,'stop'); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) else a=poly([a1 a2 a3 a4 a5 a6]); b=poly([b1 b2 b3 b4 b5 b6 b7 b8]); filt1=filter(b,a,rec); figure ('Name','Poles and Zeros','NumberTitle', zplane(b,a) end else disp('error!'); end REC_FIL.M h=findobj(gcf,'tag','edit1'); o=str2num(get(h,'string')); h=findobj(gcf,'tag','edit2'); fc1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit3'); fc2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit4'); fs=str2num(get(h,'string')); h=findobj(gcf,'tag','edit5'); r=str2num(get(h,'string')); h=findobj(gcf,'tag','pop1'); D=get(h,'value'); h=findobj(gcf,'tag','pop2'); E=get(h,'value'); h=findobj(gcf,'tag','edit6'); pf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit7'); pf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit8'); pf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit9');

'off');

'off');

'off');

'off');

'off');

sf1=str2num(get(h,'string')); h=findobj(gcf,'tag','edit10'); sf2=str2num(get(h,'string')); h=findobj(gcf,'tag','edit11'); sf3=str2num(get(h,'string')); h=findobj(gcf,'tag','edit12'); sf4=str2num(get(h,'string')); wn=fc1/(fs/2); apf1=pf1/(fs/2)*pi; apf2=pf2/(fs/2)*pi; apf3=pf3/(fs/2)*pi; asf1=sf1/(fs/2)*pi; asf2=sf2/(fs/2)*pi; asf3=sf3/(fs/2)*pi; asf4=sf4/(fs/2)*pi; [x,y]=pol2cart(apf1,1);a1=x+y*i; [x,y]=pol2cart(apf2,1);a2=x+y*i; [x,y]=pol2cart(apf3,1);a3=x+y*i; [x,y]=pol2cart(-apf1,1);a4=x+y*i; [x,y]=pol2cart(-apf2,1);a5=x+y*i; [x,y]=pol2cart(-apf3,1);a6=x+y*i; [x,y]=pol2cart(asf1,1);b1=x+y*i; [x,y]=pol2cart(asf2,1);b2=x+y*i; [x,y]=pol2cart(asf3,1);b3=x+y*i; [x,y]=pol2cart(asf4,1);b4=x+y*i; [x,y]=pol2cart(-asf1,1);b5=x+y*i; [x,y]=pol2cart(-asf2,1);b6=x+y*i; [x,y]=pol2cart(-asf3,1);b7=x+y*i; [x,y]=pol2cart(-asf4,1);b8=x+y*i; if (wn>0)&(wn<1) if D==2 & E==2 wn=fc1/(fs/2); b=fir1(o,wn); filt1=filter(b,1,rec); figure ('Name','Recorded (blue) and Filtered (yellow)','NumberTitle', 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==2 & E==3 wn=fc1/(fs/2); b=fir1(o,wn,'high'); filt1=filter(b,1,rec); figure ('Name','Recorded (blue) and Filtered (yellow)','NumberTitle', 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==2 & E==4 wn=fc1/(fs/2); b=fir1(o,wn,'band'); filt1=filter(b,1,rec); figure ('Name','Recorded (blue) and Filtered (yellow)','NumberTitle', 'off'); plot(rec);

hold on; plot(filt1,'y'); hold off; elseif D==2 & E==5 wn=fc1/(fs/2); b=fir1(o,wn,'stop'); filt1=filter(b,1,rec); figure ('Name','Recorded (blue) 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==3 & E==2 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==3 & E==3 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==3 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=cheby1(o,r,w,'bandpass'); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==3 & E==5 wn=fc1/(fs/2); [b,a]=cheby1(o,r,wn,'stop'); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==4 & E==2 wn=fc1/(fs/2);

and Filtered (yellow)','NumberTitle',

and Filtered (yellow)','NumberTitle',

and Filtered (yellow)','NumberTitle',

and Filtered (yellow)','NumberTitle',

and Filtered (yellow)','NumberTitle',

[b,a]=butter(o,wn); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) and Filtered (yellow)','NumberTitle', 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==4 & E==3 wn=fc1/(fs/2); [b,a]=butter(o,wn,'high'); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) and 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==4 & E==4 wn=fc1/(fs/2); w2=fc2/(fs/2); w=[wn w2]; [b,a]=butter(o,w,'band'); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) and 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; elseif D==4 & E==5 wn=fc1/(fs/2); [b,a]=butter(o,w,'stop'); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) and 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; else D==5 a=poly([a1 a2 a3 a4 a5 a6]); b=poly([b1 b2 b3 b4 b5 b6 b7 b8]); filt1=filter(b,a,rec); figure ('Name','Recorded (blue) and 'off'); plot(rec); hold on; plot(filt1,'y'); hold off; end else disp('error!'); end RECORD.M rec=wavrecord(5*11025,11025);

Filtered (yellow)','NumberTitle',

Filtered (yellow)','NumberTitle',

Filtered (yellow)','NumberTitle',

Filtered (yellow)','NumberTitle',

Anda mungkin juga menyukai