• Tidak ada hasil yang ditemukan

BAB V. PENUTUP

5.2 Saran

Tugas akhir ini dapat dikembangkan dengan menggunakan metode perancangan filter yang lain dan juga menggunakan perancangan filter HPF (highpass filter) atau BPF (bandpass filter).

Processing, A Practical Approach – 2nd Ed”, Prentice Hall, 2001.

[2] Proakis, John G., dan Charles M. Rader, dan Fuyun Ling, dan Chrysostomas L. Nikias., “Advanced Digital Signal Processing”, United Stated of America: Macmillan, 1992.

[3] Venkataramani, B., dan M. Bhaskar, “Digital Signal Processors,

Architecture, Programing and Application”, Singapore: MC Graw – Hill, 2002.

[4] Mitra, Sanjit K., “Digital Signal Processing, A Computer Based Approach – 3rd Ed”, Singapore: MC Graw – Hill, 2006.

[5] Mitra, Sanjit K., “Digital Signal Processing Laboratory Using Matlab”, United Stated of America: MC Graw – Hill, 1999.

% singleton*. %

% H = MULTIRATE returns the handle to a new MULTIRATE or the handle to % the existing singleton*.

%

% MULTIRATE('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MULTIRATE.M with the given input arguments. %

% MULTIRATE('Property','Value',...) creates a new MULTIRATE or raises the % existing singleton*. Starting from the left, property value pairs are

% applied to the GUI before Multirate_OpeningFunction gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Multirate_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 Multirate % Last Modified by GUIDE v2.5 22-Aug-2007 19:49:44 % Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @Multirate_OpeningFcn, ... 'gui_OutputFcn', @Multirate_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 Multirate is made visible.

function Multirate_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 Multirate (see VARARGIN)

handles.passbandripple = 0 ; handles.stopbandripple = 0 ; handles.frekuensisampling = 0 ; handles.transitionwidth = 0 ; handles.faktordecimation = 0 ; handles.faktotinterpolation = 0 ; handles.datafiltered = 0; handles.filter = 0; handles.f1 = 0; handles.f2 = 0; a = 0 ; b = 0;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes Multirate wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = Multirate_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;

function fc1_Callback(hObject, eventdata, handles)

% hObject handle to fc1 (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 fc1 as text

% str2double(get(hObject,'String')) returns contents of fc1 as a double % --- Executes during object creation, after setting all properties.

function fc1_CreateFcn(hObject, eventdata, handles)

% hObject handle to fc1 (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 pr_Callback(hObject, eventdata, handles)

% hObject handle to pr (see GCBO)

% str2double(get(hObject,'String')) returns contents of pr as a double % --- Executes during object creation, after setting all properties.

function pr_CreateFcn(hObject, eventdata, handles)

% hObject handle to pr (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 sr_Callback(hObject, eventdata, handles)

% hObject handle to sr (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 sr as text

% str2double(get(hObject,'String')) returns contents of sr as a double % --- Executes during object creation, after setting all properties.

function sr_CreateFcn(hObject, eventdata, handles)

% hObject handle to sr (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 satuan1.

function satuan1_Callback(hObject, eventdata, handles)

% hObject handle to satuan1 (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 satuan1 contents as cell array % contents{get(hObject,'Value')} returns selected item from satuan1 % --- Executes during object creation, after setting all properties.

function satuan1_CreateFcn(hObject, eventdata, handles)

% hObject handle to satuan1 (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.

function fs_Callback(hObject, eventdata, handles)

% hObject handle to fs (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of fs as text

% str2double(get(hObject,'String')) returns contents of fs as a double % --- Executes during object creation, after setting all properties.

function fs_CreateFcn(hObject, eventdata, handles)

% hObject handle to fs (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function tw_Callback(hObject, eventdata, handles)

% hObject handle to tw (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 tw as text

% str2double(get(hObject,'String')) returns contents of tw as a double % --- Executes during object creation, after setting all properties.

function tw_CreateFcn(hObject, eventdata, handles)

% hObject handle to tw (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 satuan2.

function satuan2_Callback(hObject, eventdata, handles)

% hObject handle to satuan2 (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 satuan2 contents as cell array % contents{get(hObject,'Value')} returns selected item from satuan2 % --- Executes during object creation, after setting all properties.

% handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on selection change in satuan3.

function satuan3_Callback(hObject, eventdata, handles)

% hObject handle to satuan3 (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 satuan3 contents as cell array % contents{get(hObject,'Value')} returns selected item from satuan3 % --- Executes during object creation, after setting all properties.

function satuan3_CreateFcn(hObject, eventdata, handles)

% hObject handle to satuan3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on selection change in stage.

function stage_Callback(hObject, eventdata, handles)

% hObject handle to stage (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 stage contents as cell array % contents{get(hObject,'Value')} returns selected item from stage % if (get(handles.stage,'value') == 1)

% --- Executes during object creation, after setting all properties.

function stage_CreateFcn(hObject, eventdata, handles)

% hObject handle to stage (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

% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of fd as text

% str2double(get(hObject,'String')) returns contents of fd as a double % --- Executes during object creation, after setting all properties.

function fd_CreateFcn(hObject, eventdata, handles)

% hObject handle to fd (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 fi_Callback(hObject, eventdata, handles)

% hObject handle to fi (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 fi as text

% str2double(get(hObject,'String')) returns contents of fi as a double % --- Executes during object creation, after setting all properties.

function fi_CreateFcn(hObject, eventdata, handles)

% hObject handle to fi (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 proses.

function proses_Callback(hObject, eventdata, handles)

% hObject handle to proses (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 proses contents as cell array % contents{get(hObject,'Value')} returns selected item from proses

j=get(handles.proses,'value'); if j==2 %Interpolation

set(handles.fi,'visible','on'); set(handles.fd,'visible','off'); set(handles.text8,'visible','on');

set(handles.fi,'visible','off'); set(handles.fd,'visible','on'); set(handles.text9,'visible','on'); set(handles.text8,'visible','off'); end

% --- Executes during object creation, after setting all properties.

function proses_CreateFcn(hObject, eventdata, handles)

% hObject handle to proses (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

function datain_Callback(hObject, eventdata, handles)

% hObject handle to datain (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 datain as text

% str2double(get(hObject,'String')) returns contents of datain as a double % --- Executes during object creation, after setting all properties.

function datain_CreateFcn(hObject, eventdata, handles)

% hObject handle to datain (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows. % See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');

end

% --- Executes on button press in browse.

function browse_Callback(hObject, eventdata, handles)

% hObject handle to browse (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %Mengambil nama file masukan dari komputer

[nama_file, nama_path]=uigetfile({'*.wav','File WAV (*.wav)'},... 'Buka File Untuk Masukan');

%baca data masukan

if ~isequal(nama_file, 0)

%%tambahan handles.data = handles.data(1:length(handles.data)); handles.data = handles.data'; %% guidata(hObject,handles); else return; end

%tampilkan nama file masukan dan jumlah masukan

set(handles.datain,'string',nama_file); set(handles.tampilkan,'enable','on'); set(handles.suara1,'enable','on'); guidata(hObject,handles);

% --- Executes on button press in tampilkan.

function tampilkan_Callback(hObject, eventdata, handles)

% hObject handle to tampilkan (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) %menampilkan kurva tanggapan amplitudo

axes(handles.kurva1)

% plot(handles.data);

stem(handles.data,'.'); xlabel('Nilai Data ke...')

ylabel('Tanggapan Amplitudo(dB)') guidata(hObject,handles);

% --- Executes during object creation, after setting all properties.

function jlmhN1_CreateFcn(hObject, eventdata, handles)

% hObject handle to jlmhN1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes during object creation, after setting all properties.

function jumlah2_CreateFcn(hObject, eventdata, handles)

% hObject handle to jumlah2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes during object creation, after setting all properties.

function jumlah3_CreateFcn(hObject, eventdata, handles)

% hObject handle to jumlah3 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % --- Executes on selection change in listkoefisien1.

function listkoefisien1_Callback(hObject, eventdata, handles)

% hObject handle to listkoefisien1 (see GCBO)

% contents{get(hObject,'Value')} returns selected item from listkoefisien1 % --- Executes during object creation, after setting all properties.

function listkoefisien1_CreateFcn(hObject, eventdata, handles)

% hObject handle to listkoefisien1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: listbox 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 pushbutton1.

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject handle to pushbutton1 (see GCBO)

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

legend toggle

% --- 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)

grid minor

% --- Executes on button press in zoomin.

function zoomin_Callback(hObject, eventdata, handles)

% hObject handle to zoomin (see GCBO)

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

zoom

set(handles.geser,'enable','on');

% --- Executes on button press in zoomout.

function zoomout_Callback(hObject, eventdata, handles)

% hObject handle to zoomout (see GCBO)

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

zoom out

pan off

set(handles.geser,'enable','off');

% --- Executes on button press in prosesmultirate.

function prosesmultirate_Callback(hObject, eventdata, handles)

handles.stopbandripple = str2double(get(handles.sr,'string')); handles.frekuensisampling =

konversi(str2double(get(handles.fs,'string')),get(handles.satuan2,'value')); handles.transitionwidth =

konversi(str2double(get(handles.tw,'string')),get(handles.satuan3,'value'));

stg = get(handles.stage,'value'); s1=(get(handles.satuan1,'value')); s2=(get(handles.satuan2,'value')); s3=(get(handles.satuan3,'value')); input = get(handles.datain,'string');

if isnan(handles.cuttoffrekuensi) | handles.cuttoffrekuensi<=0

errordlg('Anda harus mengisikan nilai numerik positif pada Cut - off frekuensi(fc1)','Error','modal');

return;

elseif isnan(handles.passbandripple) | handles.passbandripple<=0

errordlg('Anda harus mengisikan nilai numerik positif pada passband ripple','Error','modal'); return;

elseif isnan(handles.stopbandripple) | handles.stopbandripple<=0

errordlg('Anda harus mengisikan nilai numerik positif pada stopband ripple','Error','modal'); return;

elseif isnan(handles.frekuensisampling) | handles.frekuensisampling<=0

errordlg('Anda harus mengisikan nilai numerik positif pada frekuensi sampling','Error','modal'); return;

elseif isnan(handles.transitionwidth) | handles.transitionwidth<=0

errordlg('Anda harus mengisikan nilai numerik positif pada transition width','Error','modal'); return;

elseif isempty(input)

errordlg('Input null','Error','modal'); return; else % nothing end %======================================================================== ==

%interpolator or decimator process

if(get(handles.proses,'value') == 1) %decimator

handles.faktordecimation = str2double(get(handles.fd,'string')); if isnan(handles.faktordecimation)|handles.faktordecimation <= 1 errordlg('Masukkan faktor Decimation','Error','modal');

return; end

if (get(handles.stage,'value') == 1) % Decimator Satu tingkat

hn =

optimalmethod(handles.cuttoffrekuensi,(handles.frekuensisampling/handles.faktordecimation),ha ndles.passbandripple,handles.stopbandripple,handles.frekuensisampling,handles.faktordecimatio n,handles.frekuensisampling);

set(handles.filter.stage(1),'numerator',hn) set(handles.jlmhN1,'string',['Filter 1 : '

num2str(length(get(handles.filter.stage(1),'numerator')))])

handles.N1 = length(get(handles.filter.stage(1),'numerator')); set(handles.listkoefisien1,'string',handles.filter.stage(1).numerator') guidata(hObject,handles);

elseif(get(handles.stage,'value') == 2) % Decimator Dua tingkat

if mod(handles.faktordecimation,2) ~= 0

errordlg('Masukkan faktor Decimation Genap Kelipatan 2','Error','modal'); return; end hn1 = optimalmethod(handles.cuttoffrekuensi,(handles.frekuensisampling/(handles.faktordecimation/2)), handles.passbandripple,handles.stopbandripple,handles.frekuensisampling,handles.faktordecima tion,handles.frekuensisampling); hn2 = optimalmethod(handles.cuttoffrekuensi,(handles.frekuensisampling/(handles.faktordecimation/2))/ 2,handles.passbandripple,handles.stopbandripple,handles.frekuensisampling/(handles.faktordeci mation/2),handles.faktordecimation,handles.frekuensisampling); fs1 = handles.frekuensisampling / (handles.faktordecimation/2); fs2 = (handles.frekuensisampling / (handles.faktordecimation/2))/2; hm1 = mfilt.firdecim(handles.faktordecimation/2,hn1); hm2 = mfilt.firdecim(2,hn2); handles.filter = mfilt.cascade(hm1,hm2); set(handles.filter.stage(1),'numerator',hn1) set(handles.filter.stage(2),'numerator',hn2) set(handles.jlmhN1,'string',{['Filter 1 : '

num2str(length(get(handles.filter.stage(1),'numerator')))],...

['Filter 2 : ' num2str(length(get(handles.filter.stage(2),'numerator')))]}) handles.N1 = length(get(handles.filter.stage(1),'numerator'));

handles.N2 = length(get(handles.filter.stage(2),'numerator')); set(handles.listkoefisien1,'string',handles.filter.stage(1).numerator') guidata(hObject,handles);

else% Decimator Tiga tingkat

if mod(handles.faktordecimation,4) ~= 0

errordlg('Masukkan faktor Decimation Genap Kelipatan 4','Error','modal'); return; end hn1 = optimalmethod(handles.cuttoffrekuensi,(handles.frekuensisampling/(handles.faktordecimation/4)), handles.passbandripple,handles.stopbandripple,handles.frekuensisampling,handles.faktordecima tion,handles.frekuensisampling); hn2 = optimalmethod(handles.cuttoffrekuensi,(handles.frekuensisampling/(handles.faktordecimation/4))/ 2,handles.passbandripple,handles.stopbandripple,handles.frekuensisampling/(handles.faktordeci mation/4),handles.faktordecimation,handles.frekuensisampling); hn3 = optimalmethod(handles.cuttoffrekuensi,((handles.frekuensisampling/(handles.faktordecimation/4)) /2)/2,handles.passbandripple,handles.stopbandripple,(handles.frekuensisampling/(handles.faktor decimation/4))/2,handles.faktordecimation,handles.frekuensisampling);

hm1 = mfilt.firdecim(handles.faktordecimation/4,hn1); hm2 = mfilt.firdecim(2,hn2); hm3 = mfilt.firdecim(2,hn3); handles.filter = mfilt.cascade(hm1,hm2,hm3); set(handles.filter.stage(1),'numerator',hn1) set(handles.filter.stage(2),'numerator',hn2) set(handles.filter.stage(3),'numerator',hn3)

set(handles.jlmhN1,'string',{['Filter 1 : '

num2str(length(get(handles.filter.stage(1),'numerator')))],...

['Filter 2 : ' num2str(length(get(handles.filter.stage(2),'numerator')))],... ['Filter 3 : ' num2str(length(get(handles.filter.stage(3),'numerator')))]}) handles.N1 = length(get(handles.filter.stage(1),'numerator'));

handles.N2 = length(get(handles.filter.stage(2),'numerator')); handles.N3 = length(get(handles.filter.stage(3),'numerator'));

set(handles.listkoefisien1,'string',handles.filter.stage(1).numerator') guidata(hObject,handles);

end

else %Interpolator

handles.faktotinterpolation = str2double(get(handles.fi,'string')); if isnan(handles.faktotinterpolation)|handles.faktotinterpolation <= 1 errordlg('Masukkan faktor Interpolation','Error','modal');

return; end

if (get(handles.stage,'value') == 1)%interpolator 1 tingkat

hn = optimalmethod1(handles.cuttoffrekuensi,(handles.frekuensisampling*handles.faktotinterpolation), handles.passbandripple,handles.stopbandripple,handles.frekuensisampling,(4*handles.faktotinter polation)); hm = mfilt.firinterp(handles.faktotinterpolation); fs1 = handles.frekuensisampling * (handles.faktotinterpolation); handles.filter = mfilt.cascade(hm); set(handles.filter.stage(1),'numerator',hn) set(handles.jlmhN1,'string',['Filter 1 : '

num2str(length(get(handles.filter.stage(1),'numerator')))])

handles.N1 = length(get(handles.filter.stage(1),'numerator')); set(handles.listkoefisien1,'string',handles.filter.stage(1).numerator') guidata(hObject,handles);

elseif(get(handles.stage,'value') == 2) %interpolator 2 tingkat

if mod(handles.faktotinterpolation,2) ~= 0

errordlg('Masukkan faktor Interpolation Genap Kelipatan 2','Error','modal'); return; end hn1 = optimalmethod1(handles.cuttoffrekuensi,(handles.frekuensisampling*(handles.faktotinterpolation) ),handles.passbandripple,handles.stopbandripple,handles.frekuensisampling,(handles.faktotinter polation));

erpolation/2),(handles.faktotinterpolation/2)); fs1 = handles.frekuensisampling*(handles.faktotinterpolation/2); fs2 = (handles.frekuensisampling*(handles.faktotinterpolation/2))*2; hm1 = mfilt.firinterp(handles.faktotinterpolation/2); hm2 = mfilt.firinterp(2); handles.filter = mfilt.cascade(hm1,hm2); set(handles.filter.stage(1),'numerator',hn1) set(handles.filter.stage(2),'numerator',hn2) set(handles.jlmhN1,'string',{['Filter 1 : '

num2str(length(get(handles.filter.stage(1),'numerator')))],...

['Filter 2 : ' num2str(length(get(handles.filter.stage(2),'numerator')))]}) handles.N1 = length(get(handles.filter.stage(1),'numerator'));

handles.N2 = length(get(handles.filter.stage(2),'numerator')); set(handles.listkoefisien1,'string',handles.filter.stage(1).numerator') guidata(hObject,handles);

else%interpolator 3 tingkat

if mod(handles.faktotinterpolation,4) ~= 0

errordlg('Masukkan faktor Interpolation Genap Kelipatan 4','Error','modal'); return; end hn1 = optimalmethod1(handles.cuttoffrekuensi,(handles.frekuensisampling*(handles.faktotinterpolation/ 4)),handles.passbandripple,handles.stopbandripple,handles.frekuensisampling,(handles.faktotint erpolation/4)); hn2 = optimalmethod1(handles.cuttoffrekuensi,(handles.frekuensisampling*(handles.faktotinterpolation/ 4))*2,handles.passbandripple,handles.stopbandripple,handles.frekuensisampling*(handles.faktoti nterpolation/4),(2)); hn3 = optimalmethod1(handles.cuttoffrekuensi,((handles.frekuensisampling*(handles.faktotinterpolation/ 4))*2)*2,handles.passbandripple,handles.stopbandripple,(handles.frekuensisampling*(handles.fak totinterpolation/4))*2,(2)); fs1 = handles.frekuensisampling*(handles.faktotinterpolation/4); fs2 = (handles.frekuensisampling*(handles.faktotinterpolation/4))*2; fs3 = ((handles.frekuensisampling*(handles.faktotinterpolation/4))*2)*2; hm1 = mfilt.firinterp(handles.faktotinterpolation/4); hm2 = mfilt.firinterp(2); hm3 = mfilt.firinterp(2); handles.filter = mfilt.cascade(hm1,hm2,hm3); set(handles.filter.stage(1),'numerator',hn1) set(handles.filter.stage(2),'numerator',hn2) set(handles.filter.stage(3),'numerator',hn3)

set(handles.jlmhN1,'string',{['Filter 1 : '

num2str(length(get(handles.filter.stage(1),'numerator')))],...

['Filter 2 : ' num2str(length(get(handles.filter.stage(2),'numerator')))],... ['Filter 3 : ' num2str(length(get(handles.filter.stage(3),'numerator')))]}) handles.N1 = length(get(handles.filter.stage(1),'numerator'));

guidata(hObject,handles); end end %======================================================================== == handles.datafiltered = filter(handles.filter,handles.data); axes(handles.kurva2) stem(handles.datafiltered,'.') xlabel('Nilai Data ke...')

ylabel('Tanggapan Amplitudo(dB)') set(handles.suara2,'enable','on'); guidata(hObject,handles);

handles.cuttoffrekuensi =

konversi(str2double(get(handles.fc1,'string')),get(handles.satuan1,'value')); handles.passbandripple = str2double(get(handles.pr,'string'));

handles.stopbandripple = str2double(get(handles.sr,'string')); handles.frekuensisampling =

konversi(str2double(get(handles.fs,'string')),get(handles.satuan2,'value')); handles.transitionwidth =

konversi(str2double(get(handles.tw,'string')),get(handles.satuan3,'value'));

% menampilkan data yang diubah

[nil1,sat1]=nilaitampil1(handles.cuttoffrekuensi); set(handles.fc1,'string',nil1);

set(handles.satuan1,'value',sat1);

[nil2,sat2]=nilaitampil(handles.frekuensisampling); set(handles.fs,'string',nil2);

set(handles.satuan2,'value',sat2);

[nil3,sat3]=nilaitampil1(handles.transitionwidth); set(handles.tw,'string',nil3);

set(handles.satuan3,'value',sat3);

% Menampilkan nilai MPS

if stg==1

set(handles.jumlah2,'string',handles.N1*fs1); elseif stg==2

set(handles.jumlah2,'string',{(handles.N1*fs1)+(handles.N2*fs2)}); else

set(handles.jumlah2,'string',{(handles.N1*fs1)+(handles.N2*fs2)+(handles.N3*fs3)}); end

% Menampilkan nilai TSR

if stg==1

set(handles.jumlah3,'string',handles.N1); elseif stg==2

set(handles.jumlah3,'string',{handles.N1+handles.N2}); else

set(handles.jumlah3,'string',{handles.N1+handles.N2+handles.N3}); end

handles.jumlah_data=length(handles.data); set(handles.jumlahin,'string',handles.jumlah_data); handles.jumlah_data1=length(handles.datafiltered); set(handles.jumlahout,'string',handles.jumlah_data1);

% --- Executes on button press in togglebutton8.

function togglebutton8_Callback(hObject, eventdata, handles)

% hObject handle to togglebutton8 (see GCBO)

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

---function Menu_Callback(hObject, eventdata, handles)

% hObject handle to Menu (see GCBO)

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

---function Reset_Callback(hObject, eventdata, handles)

% hObject handle to Reset (see GCBO)

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

axes(handles.kurva1) handles.data = 0; plot(handles.data) xlabel('Nilai Data ke...')

ylabel('Tanggapan Amplitudo(dB)') axes(handles.kurva2)

handles.datafiltered = 0; plot(handles.datafiltered) xlabel('Nilai Data ke...')

ylabel('Tanggapan Amplitudo(dB)') set(handles.fc1,'string',''); set(handles.pr,'string',''); set(handles.tw,'string',''); set(handles.sr,'string',''); set(handles.fs,'string',''); set(handles.fd,'string',''); set(handles.fi ,'string',''); set(handles.datain,'string',''); set(handles.jlmhN1,'string',''); set(handles.listkoefisien1,'string',''); set(handles.jumlah2,'string',''); set(handles.jumlah3,'string',''); guidata(hObject,handles); %

---function Simpan_Callback(hObject, eventdata, handles)

% hObject handle to Simpan (see GCBO)

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

wavwrite(handles.datafiltered,file); guidata(hObject,handles); else return; end %

---function Keluar_Callback(hObject, eventdata, handles)

% hObject handle to Keluar (see GCBO)

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

quit = questdlg(['Keluar ',get(handles.figure1,'name') ' ?'],... ['Keluar ',get(handles.figure1,'name') '...'],...

'Ya','Tidak','Tidak'); if strcmp(quit,'Tidak') return;

end

delete(handles.figure1)

%

---function Untitled_5_Callback(hObject, eventdata, handles)

% hObject handle to Untitled_5 (see GCBO)

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

---function Bantuan_Callback(hObject, eventdata, handles)

% hObject handle to Bantuan (see GCBO)

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

---function Arti_Callback(hObject, eventdata, handles)

% hObject handle to Arti (see GCBO)

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

Multirateku_help

%

---function Cara_Callback(hObject, eventdata, handles)

% hObject handle to Cara (see GCBO)

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

Using_MSP

%

---function Pembuat_Callback(hObject, eventdata, handles)

% hObject handle to Pembuat (see GCBO)

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

function out_Callback(hObject, eventdata, handles)

% hObject handle to out (see GCBO)

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

quit = questdlg(['Keluar ',get(handles.figure1,'name') ' ?'],... ['Keluar ',get(handles.figure1,'name') '...'],...

'Ya','Tidak','Tidak'); if strcmp(quit,'Tidak') return;

end

delete(handles.figure1)

% --- Executes on selection change in jlmhN1.

function jlmhN1_Callback(hObject, eventdata, handles)

% hObject handle to jlmhN1 (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 jlmhN1 contents as cell array % contents{get(hObject,'Value')} returns selected item from jlmhN1

if(get(handles.jlmhN1,'value')==1)

% set(handles.filter.stage(1),'numerator',hn1)

set(handles.listkoefisien1,'string',handles.filter.stage(1).numerator'); elseif(get(handles.jlmhN1,'value')==2)

set(handles.listkoefisien1,'string',handles.filter.stage(2).numerator'); else

set(handles.listkoefisien1,'string',handles.filter.stage(3).numerator'); end

function hn = optimalmethod(fc1,variable,pr,sr,fs,factor,freqSamp)

%nilai nilai

[ap,as]=konversidB(pr,sr);

%menghitung koefisien tapis menurut jenis tanggapan lowpass filter

f1 = fc1;

f2 = variable - (freqSamp/(2*factor)); if f1 > f2

errordlg('Masukkan Frekuensi sampling < 2*M*Cut - off frekuensi','Error','modal'); return;

end F = [f1 f2]; M = [1 0]; dev = [ap as];

[N,fo,ao,W] = firpmord(F,M,dev,fs); hn = firpm(N,fo,ao,W); function hn = optimalmethod1(fc1,variable,pr,sr,fs,factor) %nilai nilai [ap,as]=konversidB(pr,sr);

errordlg('Masukkan Frekuensi sampling < 8*Cut - off frekuensi','Error','modal'); return;

end F = [f1 f2]; M = [1 0]; dev = [ap as];

[N,fo,ao,W] = firpmord(F,M,dev,fs); hn = firpm(N,fo,ao,W);

function [Ap, As] = konversidB(a,b) Ap =((10^(a/20))-1)/((10^(a/20))+1); As = 10^(-b/20);

function nilai = konversi(n,x) if x == 1 nilai = n*10^0; elseif x == 2 nilai = n*10^3;

Dokumen terkait