SEMUA EVENT CALLBACK GUI MATLAB:
function varargout = iir_parallel_form(varargin)
% IIR_PARALLEL_FORM MATLAB code for iir_parallel_form.fig
% IIR_PARALLEL_FORM, by itself, creates a new IIR_PARALLEL_FORM or raises the existing
% singleton*.
%
% H = IIR_PARALLEL_FORM returns the handle to a new IIR_PARALLEL_FORM or the handle to
% the existing singleton*.
%
% IIR_PARALLEL_FORM('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in IIR_PARALLEL_FORM.M with the given input arguments.
%
% IIR_PARALLEL_FORM('Property','Value',...) creates a new IIR_PARALLEL_FORM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before iir_parallel_form_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to iir_parallel_form_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 iir_parallel_form
% Last Modified by GUIDE v2.5 17-Jun-2017 14:00:15
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @iir_parallel_form_OpeningFcn, ...
'gui_OutputFcn', @iir_parallel_form_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 iir_parallel_form is made visible.
function iir_parallel_form_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 iir_parallel_form (see VARARGIN)
% Choose default command line output for iir_parallel_form
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes iir_parallel_form wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = iir_parallel_form_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 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)
%Menetapkan n0=1
set(handles.n0,'string',1);
% Membaca n0, n1, dan n2
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs,'String'));
%Memilih pilihan dari menu popup
switch get(handles.popupmenu1,'Value')
case 1
n = [n1:n2]; x = [(n-n0) == 0];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Impulse Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Impulse Diskret');
pause(0.1);
end
case 2
n = [n1:n2]; x = [(n-n0) >= 0];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Tangga Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Tangga Diskret');
pause(0.1)
end
case 3
n = [n1:n2]; x = [(n-n0) >= 0].*[(eksp).^(n-n0)];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Eksponensial Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Eksponensial Diskret');
pause(0.1)
end
case 4
n = [n1:n2]; x = [(n-n0) >= 0].*[A*sin(2*pi*(Frek)*((n-n0)/Fs)+Fase)];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Sinusoidal Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Sinusoidal Diskret');
pause(0.1)
end
case 5
n = [n1:n2]; x = [(n-n0) >= 0].*(rand(1,(n2-n1+1))-0.5);
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Acak Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Acak Diskret');
pause(0.1)
end
%Menetapkan n0=1
set(handles.n0,'string',1);
end
function n0_Callback(hObject, eventdata, handles)
% hObject handle to n0 (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 n0 as text
% str2double(get(hObject,'String')) returns contents of n0 as a double
% --- Executes during object creation, after setting all properties.
function n0_CreateFcn(hObject, eventdata, handles)
% hObject handle to n0 (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 n1_Callback(hObject, eventdata, handles)
% hObject handle to n1 (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 n1 as text
% str2double(get(hObject,'String')) returns contents of n1 as a double
% --- Executes during object creation, after setting all properties.
function n1_CreateFcn(hObject, eventdata, handles)
% hObject handle to n1 (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 n2_Callback(hObject, eventdata, handles)
% hObject handle to n2 (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 n2 as text
% str2double(get(hObject,'String')) returns contents of n2 as a double
% --- Executes during object creation, after setting all properties.
function n2_CreateFcn(hObject, eventdata, handles)
% hObject handle to n2 (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 popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function eksp_Callback(hObject, eventdata, handles)
% hObject handle to eksp (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 eksp as text
% str2double(get(hObject,'String')) returns contents of eksp as a double
% --- Executes during object creation, after setting all properties.
function eksp_CreateFcn(hObject, eventdata, handles)
% hObject handle to eksp (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 A_Callback(hObject, eventdata, handles)
% hObject handle to A (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 A as text
% str2double(get(hObject,'String')) returns contents of A as a double
% --- Executes during object creation, after setting all properties.
function A_CreateFcn(hObject, eventdata, handles)
% hObject handle to A (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 Frek_Callback(hObject, eventdata, handles)
% hObject handle to Frek (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 Frek as text
% str2double(get(hObject,'String')) returns contents of Frek as a double
% --- Executes during object creation, after setting all properties.
function Frek_CreateFcn(hObject, eventdata, handles)
% hObject handle to Frek (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 Fase_Callback(hObject, eventdata, handles)
% hObject handle to Fase (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 Fase as text
% str2double(get(hObject,'String')) returns contents of Fase as a double
% --- Executes during object creation, after setting all properties.
function Fase_CreateFcn(hObject, eventdata, handles)
% hObject handle to Fase (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Fs_Callback(hObject, eventdata, handles)
% hObject handle to Fs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Fs as text
% str2double(get(hObject,'String')) returns contents of Fs as a double
% --- Executes during object creation, after setting all properties.
function Fs_CreateFcn(hObject, eventdata, handles)
% hObject handle to Fs (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global n0;
global n1;
global x;
% Membaca n0, n1, dan n2
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs1,'String'));
%Membaca parameter untuk sinyal kotak dan segitiga
lebar = str2num(get(handles.lebar, 'String'));
%Memilih pilihan dari menu popup
switch get(handles.popupmenu1,'Value')
case 1
n = [n1:n2]; x = [(n-n0) == 0];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x,'linewidth',2,'color','b'); title('Runtun Impulse Diskret');
case 2
n = [n1:n2]; x = [(n-n0) >= 0];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x,'linewidth',2,'color','b'); title('Runtun Tangga Diskret');
case 3
n = [n1:n2]; x = [(n-n0) >= 0].*[(eksp).^(n-n0)];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x,'linewidth',2,'color','b'); title('Runtun Eksponensial Diskret');
case 4
n = [n1:n2]; x = [(n-n0) >= 0].*[A*sin(2*pi*(Frek)*((n-n0)/Fs)+Fase)];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x,'linewidth',2,'color','b'); title('Runtun Sinusoidal Diskret');
case 5
n = [n1:n2]; x = [(n-n0) >= 0].*(rand(1,(n2-n1+1))-0.5);
%Menampilkan grafik
axes(handles.axes1)
stem(n,x,'linewidth',2,'color','b'); title('Runtun Acak Diskret');
case 6
n = [n1:n2]; x = [(n-n0) >= 0];
ny = [n1:n2]; xy = [(ny-lebar-n0-1) >= 0];
x = x - xy;
%Menampilkan grafik
axes(handles.axes1)
stem(n,x,'linewidth',2,'color','b'); title('Runtun Kotak Diskret');
case 7
n = [n1:n2]; x = n.*[n >= 0];
ny = [n1:n2]; xy = ny.*[(ny-lebar-1) >= 0];
x = (x - xy)/lebar;
nb = [n1+n0:n2+n0];
%Menetapkan rentang baru
set(handles.n1,'string',(n1+n0));
set(handles.n2,'string',(n2+n0));
%Menampilkan grafik
axes(handles.axes1)
stem(nb,x,'linewidth',2,'color','b'); title('Runtun Segitiga Siku Diskret');
case 8
n = [n1:n2]; x = n.*[n >= 0];
x2 = [zeros(1,lebar), x(1:end-lebar)];
x1 = -x;
x1 = [zeros(1,0.5*lebar), x1(1:end-0.5*lebar)];
nb1 = n1+n0; nb2 = n2+n0;
nb = [nb1:nb2];
%Menetapkan rentang baru
set(handles.n1,'string',(nb1));
set(handles.n2,'string',(nb2));
%Menghasilkan sinyal segitiga sama kaki
x = (x + 2*x1+x2)/(0.5*lebar);
%Menampilkan grafik
axes(handles.axes1)
stem(nb,x,'linewidth',2,'color','b'); title('Runtun Segitiga Sama Kaki');
case 9
n = [n1:n2]; x = n.*[n >= 0];
x2 = [zeros(1,lebar), x(1:end-lebar)];
x3 = [zeros(1,3*lebar), x(1:end-3*lebar)];
x1 = x;
x1 = [zeros(1,2*lebar), x1(1:end-2*lebar)];
nb1 = n1+n0; nb2 = n2+n0;
nb = [nb1:nb2];
%Menetapkan rentang baru
set(handles.n1,'string',(nb1));
set(handles.n2,'string',(nb2));
%Menghasilkan sinyal segitiga sama kaki
x = (x - x2 - x1 + x3)/lebar;
%Menampilkan grafik
axes(handles.axes1)
stem(nb,x,'linewidth',2,'color','b'); title('Runtun Trapesium Diskret');
end
% --- Executes on button press in togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton1 (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 togglebutton1
global x;
status_tombol = get(hObject,'Value')
if status_tombol == get(hObject,'Max')
set(handles.togglebutton1,'String','HENTIKAN');
elseif status_tombol == get(hObject,'Min')
set(handles.togglebutton1,'String','ANIMASIKAN');
end
% Membaca n0, n1, dan n2
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs,'String'));
%Memilih pilihan dari menu popup
switch get(handles.popupmenu1,'Value')
case 1
n = [n1:n2]; x = [(n-n0) == 0];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Impulse Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
status_tombol = get(hObject,'Value');
if (~status_tombol)
break;
end
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Impulse Diskret');
pause(0.1);
end
status_tombol = 0;
set(handles.togglebutton1,'String','ANIMASIKAN');
case 2
n = [n1:n2]; x = [(n-n0) >= 0];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Tangga Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Tangga Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton1,'String','ANIMASIKAN');
case 3
n = [n1:n2]; x = [(n-n0) >= 0].*[(eksp).^(n-n0)];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Eksponensial Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Eksponensial Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton1,'String','ANIMASIKAN');
case 4
n = [n1:n2]; x = [(n-n0) >= 0].*[A*sin(2*pi*(Frek)*((n-n0)/Fs)+Fase)];
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Sinusoidal Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Sinusoidal Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton1,'String','ANIMASIKAN');
case 5
n = [n1:n2]; x = [(n-n0) >= 0].*(rand(1,(n2-n1+1))-0.5);
%Menampilkan grafik
axes(handles.axes1)
stem(n,x); title('Runtun Acak Diskret');
%Animasi
for geser = 1:(n2-n1)
x =circshift(x',1);
x=x';
if (geser <= (n2-n0))
set(handles.n0,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes1)
stem(n,x); title('Runtun Acak Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton1,'String','ANIMASIKAN');
%Menetapkan n0 = 0
%set(handles.n0,'string',0);
end
% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton2 (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 togglebutton2
global x1;
status_tombol = get(hObject,'Value')
if status_tombol == get(hObject,'Max')
set(handles.togglebutton2,'String','HENTIKAN');
elseif status_tombol == get(hObject,'Min')
set(handles.togglebutton2,'String','ANIMASIKAN');
end
% Membaca n0, n1, dan n2
n0 = str2num(get(handles.n01,'String'));
n1 = str2num(get(handles.n11,'String'));
n2 = str2num(get(handles.n21,'String'));
eksp = str2num(get(handles.eksp1,'String'));
%Membaca parameter-parameter sinusoidal
A = str2num(get(handles.A1,'String'));
Frek = str2num(get(handles.Frek1,'String'));
Fase = str2num(get(handles.Fase1,'String'));
Fs = str2num(get(handles.Fs1,'String'));
%Memilih pilihan dari menu popup
switch get(handles.popupmenu2,'Value')
case 1
n = [n1:n2]; x1 = [(n-n0) == 0];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1); title('Runtun Impulse Diskret');
%Animasi
for geser = 1:(n2-n1)
x1 =circshift(x1',1);
x1=x1';
status_tombol = get(hObject,'Value');
if (~status_tombol)
break;
end
if (geser <= (n2-n0))
set(handles.n01,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes2)
stem(n,x1); title('Runtun Impulse Diskret');
pause(0.1);
end
status_tombol = 0;
set(handles.togglebutton2,'String','ANIMASIKAN');
case 2
n = [n1:n2]; x1 = [(n-n0) >= 0];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1); title('Runtun Tangga Diskret');
%Animasi
for geser = 1:(n2-n1)
x1 =circshift(x1',1);
x1=x1';
if (geser <= (n2-n0))
set(handles.n01,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes2)
stem(n,x1); title('Runtun Tangga Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton2,'String','ANIMASIKAN');
case 3
n = [n1:n2]; x1 = [(n-n0) >= 0].*[(eksp).^(n-n0)];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1); title('Runtun Eksponensial Diskret');
%Animasi
for geser = 1:(n2-n1)
x1 =circshift(x1',1);
x1=x1';
if (geser <= (n2-n0))
set(handles.n01,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes2)
stem(n,x1); title('Runtun Eksponensial Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton2,'String','ANIMASIKAN');
case 4
n = [n1:n2]; x1 = [(n-n0) >= 0].*[A*sin(2*pi*(Frek)*((n-n0)/Fs)+Fase)];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1); title('Runtun Sinusoidal Diskret');
%Animasi
for geser = 1:(n2-n1)
x1 =circshift(x1',1);
x1=x1';
if (geser <= (n2-n0))
set(handles.n01,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes2)
stem(n,x1); title('Runtun Sinusoidal Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton2,'String','ANIMASIKAN');
case 5
n = [n1:n2]; x1 = [(n-n0) >= 0].*(rand(1,(n2-n1+1))-0.5);
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1); title('Runtun Acak Diskret');
%Animasi
for geser = 1:(n2-n1)
x1 =circshift(x1',1);
x1=x1';
if (geser <= (n2-n0))
set(handles.n01,'string',(n0+geser));
end
if (geser > (n2-n0))
break;
%set(handles.n0,'string',(geser-(n2-n1)));
end
axes(handles.axes2)
stem(n,x1); title('Runtun Acak Diskret');
pause(0.1)
end
status_tombol = 0;
set(handles.togglebutton2,'String','ANIMASIKAN');
%Menetapkan n0 = 0
%set(handles.n0,'string',0);
end
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x1;
% Membaca n0, n1, dan n2
n0 = str2num(get(handles.n01,'String'));
n1 = str2num(get(handles.n11,'String'));
n2 = str2num(get(handles.n21,'String'));
eksp = str2num(get(handles.eksp1,'String'));
%Membaca parameter-parameter sinusoidal
A = str2num(get(handles.A1,'String'));
Frek = str2num(get(handles.Frek1,'String'));
Fase = str2num(get(handles.Fase1,'String'));
Fs = str2num(get(handles.Fs1,'String'));
%Membaca parameter untuk sinyal kotak, segitiga, dan trapesium
lebar = str2num(get(handles.lebar1,'String'));
%Memilih pilihan dari menu popup
switch get(handles.popupmenu2,'Value')
case 1
n = [n1:n2]; x1 = [(n-n0) == 0];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1,'linewidth',2,'color','g'); title('Runtun Impulse Diskret');
case 2
n = [n1:n2]; x1 = [(n-n0) >= 0];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1,'linewidth',2,'color','g'); title('Runtun Tangga Diskret');
case 3
n = [n1:n2]; x1 = [(n-n0) >= 0].*[(eksp).^(n-n0)];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1,'linewidth',2,'color','g'); title('Runtun Eksponensial Diskret');
case 4
n = [n1:n2]; x1 = [(n-n0) >= 0].*[A*sin(2*pi*(Frek)*((n-n0)/Fs)+Fase)];
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1,'linewidth',2,'color','g'); title('Runtun Sinusoidal Diskret');
case 5
n = [n1:n2]; x1 = [(n-n0) >= 0].*(rand(1,(n2-n1+1))-0.5);
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1,'linewidth',2,'color','g'); title('Runtun Acak Diskret');
case 6
n = [n1:n2]; x = [(n-n0) >= 0];
ny = [n1:n2]; xy = [(ny-lebar-n0-1) >= 0];
x1 = x - xy;
%Menampilkan grafik
axes(handles.axes2)
stem(n,x1,'linewidth',2,'color','g'); title('Runtun Kotak Diskret');
case 7
n = [n1:n2]; x = n.*[n >= 0];
ny = [n1:n2]; xy = ny.*[(ny-lebar-1) >= 0];
x1 = (x - xy)/lebar;
nb = [n1+n0:n2+n0];
%Menetapkan rentang baru
set(handles.n11,'string',(n1+n0));
set(handles.n21,'string',(n2+n0));
%Menampilkan grafik
axes(handles.axes2)
stem(nb,x1,'linewidth',2,'color','g'); title('Runtun Segitiga Siku Diskret');
case 8
n = [n1:n2]; x = n.*[n >= 0];
x2 = [zeros(1,lebar), x(1:end-lebar)];
x3 = -x;
x3 = [zeros(1,0.5*lebar), x3(1:end-0.5*lebar)];
nb1 = n1+n0; nb2 = n2+n0;
nb = [nb1:nb2];
%Menetapkan rentang baru
set(handles.n11,'string',(nb1));
set(handles.n21,'string',(nb2));
%Menghasilkan sinyal segitiga sama kaki
x1 = (x + 2*x3+x2)/(0.5*lebar);
%Menampilkan grafik
axes(handles.axes2)
stem(nb,x1,'linewidth',2,'color','g'); title('Runtun Segitiga Sama Kaki');
case 9
n = [n1:n2]; x = n.*[n >= 0];
x2 = [zeros(1,lebar), x(1:end-lebar)];
x3 = [zeros(1,3*lebar), x(1:end-3*lebar)];
x4 = x;
x4 = [zeros(1,2*lebar), x4(1:end-2*lebar)];
nb1 = n1+n0; nb2 = n2+n0;
nb = [nb1:nb2];
%Menetapkan rentang baru
set(handles.n11,'string',(nb1));
set(handles.n21,'string',(nb2));
%Menghasilkan sinyal segitiga sama kaki
x1 = (x - x2 - x4 + x3)/lebar;
%Menampilkan grafik
axes(handles.axes2)
stem(nb,x1,'linewidth',2,'color','g'); title('Runtun Trapesium Diskret');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu2 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu2
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function eksp1_Callback(hObject, eventdata, handles)
% hObject handle to eksp1 (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 eksp1 as text
% str2double(get(hObject,'String')) returns contents of eksp1 as a double
% --- Executes during object creation, after setting all properties.
function eksp1_CreateFcn(hObject, eventdata, handles)
% hObject handle to eksp1 (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 Fs1_Callback(hObject, eventdata, handles)
% hObject handle to 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 Fs1 as text
% str2double(get(hObject,'String')) returns contents of Fs1 as a double
% --- Executes during object creation, after setting all properties.
function Fs1_CreateFcn(hObject, eventdata, handles)
% hObject handle to 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 && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Fase1_Callback(hObject, eventdata, handles)
% hObject handle to Fase1 (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 Fase1 as text
% str2double(get(hObject,'String')) returns contents of Fase1 as a double
% --- Executes during object creation, after setting all properties.
function Fase1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Fase1 (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 Frek1_Callback(hObject, eventdata, handles)
% hObject handle to Frek1 (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 Frek1 as text
% str2double(get(hObject,'String')) returns contents of Frek1 as a double
% --- Executes during object creation, after setting all properties.
function Frek1_CreateFcn(hObject, eventdata, handles)
% hObject handle to Frek1 (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 A1_Callback(hObject, eventdata, handles)
% hObject handle to A11 (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 A11 as text
% str2double(get(hObject,'String')) returns contents of A11 as a double
% --- Executes during object creation, after setting all properties.
function A1_CreateFcn(hObject, eventdata, handles)
% hObject handle to A11 (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 n21_Callback(hObject, eventdata, handles)
% hObject handle to n21 (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 n21 as text
% str2double(get(hObject,'String')) returns contents of n21 as a double
% --- Executes during object creation, after setting all properties.
function n21_CreateFcn(hObject, eventdata, handles)
% hObject handle to n21 (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 n11_Callback(hObject, eventdata, handles)
% hObject handle to n11 (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 n11 as text
% str2double(get(hObject,'String')) returns contents of n11 as a double
% --- Executes during object creation, after setting all properties.
function n11_CreateFcn(hObject, eventdata, handles)
% hObject handle to n11 (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 n01_Callback(hObject, eventdata, handles)
% hObject handle to n01 (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 n01 as text
% str2double(get(hObject,'String')) returns contents of n01 as a double
% --- Executes during object creation, after setting all properties.
function n01_CreateFcn(hObject, eventdata, handles)
% hObject handle to n01 (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 pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
global x1;
% Membaca n0, n1, dan n2 untuk sinyal 1
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal untuk sinyal 1
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs,'String'));
n = min(min(n1),min(n11)):max(max(n2),max(n21)); % durasi dari y(n)
y1 = zeros(1,length(n)); y2 = y1; % inisialisasi
y1(find((n>=min(n1))&(n<=max(n2))==1))=x; % x1 dengan durasi y
y2(find((n>=min(n11))&(n<=max(n21))==1))=x1; % x2 dengan durasi y
y = y1+y2; % runtun penjumlahan
%Mereset axes3
cla(handles.axes3,'reset');
axes(handles.axes3)
stem(n,y,'linewidth',1.5,'color','r'); title('Runtun Penjumlahan');
%Menghitung FFT atas sinyal penjumlahan
Fs = str2num(get(handles.Fs,'String'));
nfft = 512; % Panjang FFT
%Menghitung FFT
Y = fft(y,nfft);
% FFT berwatak simetris, buang setengah bagiannya
Y = Y(1:nfft/2);
% Mengambil magnitudo
my = abs(Y);
% Vektor Frekuensi
f = (0:nfft/2-1)*Fs/nfft;
axes(handles.axes4);
plot(f,my,'linewidth',1.5,'color','r'); grid on;
title('FFT atas sinyal penjumlahan'); xlabel('Hz');
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
global x1;
% Membaca n0, n1, dan n2 untuk sinyal 1
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal untuk sinyal 1
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs,'String'));
% Membaca n0, n1, dan n2
n01 = str2num(get(handles.n01,'String'));
n11 = str2num(get(handles.n11,'String'));
n21 = str2num(get(handles.n21,'String'));
eksp1 = str2num(get(handles.eksp1,'String'));
%Membaca parameter-parameter sinusoidal
A1 = str2num(get(handles.A1,'String'));
Frek1 = str2num(get(handles.Frek1,'String'));
Fase1 = str2num(get(handles.Fase1,'String'));
Fs1 = str2num(get(handles.Fs1,'String'));
n = min(min(n1),min(n11)):max(max(n2),max(n21)); % durasi dari y(n)
y1 = zeros(1,length(n)); y2 = y1; % inisialisasi
y1(find((n>=min(n1))&(n<=max(n2))==1))=x; % x1 dengan durasi y
y2(find((n>=min(n11))&(n<=max(n21))==1))=x1; % x2 dengan durasi y
y = y1.*y2; % runtun perkalian
axes(handles.axes3)
stem(n,y,'linewidth',2,'color','r'); title('Runtun Perkalian');
%Menghitung FFT atas sinyal perkalian
Fs = str2num(get(handles.Fs,'String'));
nfft = 512; % Panjang FFT
%Menghitung FFT
Y = fft(y,nfft);
% FFT berwatak simetris, buang setengah bagiannya
Y = Y(1:nfft/2);
% Mengambil magnitudo
my = abs(Y);
% Vektor Frekuensi
f = (0:nfft/2-1)*Fs/nfft;
axes(handles.axes4);
plot(f,my,'linewidth',2,'color','r'); grid on;
title('FFT atas sinyal perkalian'); xlabel('Hz');
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
global x1;
% Membaca n0, n1, dan n2 untuk sinyal 1
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal untuk sinyal 1
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs,'String'));
% Membaca n0, n1, dan n2
n01 = str2num(get(handles.n01,'String'));
n11 = str2num(get(handles.n11,'String'));
n21 = str2num(get(handles.n21,'String'));
eksp1 = str2num(get(handles.eksp1,'String'));
%Membaca parameter-parameter sinusoidal
A1 = str2num(get(handles.A1,'String'));
Frek1 = str2num(get(handles.Frek1,'String'));
Fase1 = str2num(get(handles.Fase1,'String'));
Fs1 = str2num(get(handles.Fs1,'String'));
n = min(min(n1),min(n11)):max(max(n2),max(n21)); % durasi dari y(n)
y1 = zeros(1,length(n)); y2 = y1; % inisialisasi
y1(find((n>=min(n1))&(n<=max(n2))==1))=x; % x1 dengan durasi y
y2(find((n>=min(n11))&(n<=max(n21))==1))=x1; % x2 dengan durasi y
y = y1-y2; % runtun pengurangan
axes(handles.axes3)
stem(n,y,'linewidth',2,'color','r'); title('Runtun Pengurangan');
%Menghitung FFT atas sinyal perkalian
Fs = str2num(get(handles.Fs,'String'));
nfft = 512; % Panjang FFT
%Menghitung FFT
Y = fft(y,nfft);
% FFT berwatak simetris, buang setengah bagiannya
Y = Y(1:nfft/2);
% Mengambil magnitudo
my = abs(Y);
% Vektor Frekuensi
f = (0:nfft/2-1)*Fs/nfft;
axes(handles.axes4);
plot(f,my,'linewidth',2,'color','r'); grid on;
title('FFT atas sinyal pengurangan'); xlabel('Hz');
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
global x1;
% Membaca n0, n1, dan n2 untuk sinyal 1
n0 = str2num(get(handles.n0,'String'));
n1 = str2num(get(handles.n1,'String'));
n2 = str2num(get(handles.n2,'String'));
eksp = str2num(get(handles.eksp,'String'));
%Membaca parameter-parameter sinusoidal untuk sinyal 1
A = str2num(get(handles.A,'String'));
Frek = str2num(get(handles.Frek,'String'));
Fase = str2num(get(handles.Fase,'String'));
Fs = str2num(get(handles.Fs,'String'));
% Membaca n0, n1, dan n2
n01 = str2num(get(handles.n01,'String'));
n11 = str2num(get(handles.n11,'String'));
n21 = str2num(get(handles.n21,'String'));
eksp1 = str2num(get(handles.eksp1,'String'));
%Membaca parameter-parameter sinusoidal
A1 = str2num(get(handles.A1,'String'));
Frek1 = str2num(get(handles.Frek1,'String'));
Fase1 = str2num(get(handles.Fase1,'String'));
Fs1 = str2num(get(handles.Fs1,'String'));
%nyb = n1+n11; nye = length(x) + length(x1);
%ny = [nyb:nye];
n_bawah = n1+n11;
batasatas = length(x) + length(x1);
%n_atas=batasatas+batasatas-1;
ny=n_bawah:batasatas-(abs(n_bawah)+2);
length(ny)
y = conv(double(x),double(x1)); % runtun konvolusi
length(y)
axes(handles.axes3)
stem(ny,y,'linewidth',1,'color','r'); title('Runtun Hasil Konvolusi');
%Menghitung FFT atas sinyal perkalian
Fs = str2num(get(handles.Fs,'String'));
nfft = 512; % Panjang FFT
%Menghitung FFT
Y = fft(y,nfft);
% FFT berwatak simetris, buang setengah bagiannya
Y = Y(1:nfft/2);
% Mengambil magnitudo
my = abs(Y);
% Vektor Frekuensi
f = (0:nfft/2-1)*Fs/nfft;
axes(handles.axes4);
plot(f,my,'linewidth',2.5,'color','r'); grid on;
title('FFT atas sinyal konvolusi'); xlabel('Hz');
function lebar_Callback(hObject, eventdata, handles)
% hObject handle to lebar (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 lebar as text
% str2double(get(hObject,'String')) returns contents of lebar as a double
% --- Executes during object creation, after setting all properties.
function lebar_CreateFcn(hObject, eventdata, handles)
% hObject handle to lebar (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 edit18_Callback(hObject, eventdata, handles)
% hObject handle to edit18 (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 edit18 as text
% str2double(get(hObject,'String')) returns contents of edit18 as a double
% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit18 (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 lebar1_Callback(hObject, eventdata, handles)
% hObject handle to lebar1 (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 lebar1 as text
% str2double(get(hObject,'String')) returns contents of lebar1 as a double
% --- Executes during object creation, after setting all properties.
function lebar1_CreateFcn(hObject, eventdata, handles)
% hObject handle to lebar1 (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 edit20_Callback(hObject, eventdata, handles)
% hObject handle to edit20 (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 edit20 as text
% str2double(get(hObject,'String')) returns contents of edit20 as a double
% --- Executes during object creation, after setting all properties.
function edit20_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit20 (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 pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
% Membaca semua koefisien tapis parallel
a11 = str2num(get(handles.a11,'String'));
a21 = str2num(get(handles.a21,'String'));
a12 = str2num(get(handles.a12,'String'));
a22 = str2num(get(handles.a22,'String'));
c0 = str2num(get(handles.c0,'String'));
b10 = str2num(get(handles.b10,'String'));
b11 = str2num(get(handles.b11,'String'));
b20 = str2num(get(handles.b20,'String'));
b21 = str2num(get(handles.b21,'String'));
% Konversi dari PARALLEL ke DIRECT
B = [b10 b11; b20 b21];
A = [1 a11 a12; 1 a21 a22];
[b,a] = par2dir(c0,B,A);
% Menghitung Tanggapan Frekuensi
[h,w] = freqz(b,a,'whole',2001);
axes(handles.axes2);
plot(w/pi,20*log10(abs(h)),'linewidth',2,'color','r'); grid on;
ax = gca;
ax.YLim = [-100 20];
ax.XTick = 0:.5:2;
xlabel('Frekuensi Ternormalisasi (\times\pi rad/cuplik)')
ylabel('Magnitudo (dB)'); title('Tanggapan Frekuensi Tapis')
function cf2_Callback(hObject, eventdata, handles)
% hObject handle to cf2 (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 cf2 as text
% str2double(get(hObject,'String')) returns contents of cf2 as a double
% --- Executes during object creation, after setting all properties.
function cf2_CreateFcn(hObject, eventdata, handles)
% hObject handle to cf2 (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 cf1_Callback(hObject, eventdata, handles)
% hObject handle to cf1 (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 cf1 as text
% str2double(get(hObject,'String')) returns contents of cf1 as a double
% --- Executes during object creation, after setting all properties.
function cf1_CreateFcn(hObject, eventdata, handles)
% hObject handle to cf1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function N_Callback(hObject, eventdata, handles)
% hObject handle to N (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of N as text
% str2double(get(hObject,'String')) returns contents of N as a double
% --- Executes during object creation, after setting all properties.
function N_CreateFcn(hObject, eventdata, handles)
% hObject handle to N (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x;
% Membaca semua koefisien tapis parallel
a11 = str2num(get(handles.a11,'String'));
a21 = str2num(get(handles.a21,'String'));
a12 = str2num(get(handles.a12,'String'));
a22 = str2num(get(handles.a22,'String'));
c0 = str2num(get(handles.c0,'String'));
b10 = str2num(get(handles.b10,'String'));
b11 = str2num(get(handles.b11,'String'));
b20 = str2num(get(handles.b20,'String'));
b21 = str2num(get(handles.b21,'String'));
% Konversi dari PARALLEL ke DIRECT
B = [b10 b11; b20 b21];
A = [1 a11 a12; 1 a21 a22];
[b,a] = par2dir(c0,B,A);
% Menghitung Hasil Penapisan
y = filter(b,a,x);
axes(handles.axes3);
t = 0:length(x)-1; %vektor indeks
stem(t,y,'linewidth',2,'color','g'); title('Keluaran Tapis')
% --- Executes on button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (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 pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function c0_Callback(hObject, eventdata, handles)
% hObject handle to c0 (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 c0 as text
% str2double(get(hObject,'String')) returns contents of c0 as a double
% --- Executes during object creation, after setting all properties.
function c0_CreateFcn(hObject, eventdata, handles)
% hObject handle to c0 (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 b1_Callback(hObject, eventdata, handles)
% hObject handle to b1 (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 b1 as text
% str2double(get(hObject,'String')) returns contents of b1 as a double
% --- Executes during object creation, after setting all properties.
function b1_CreateFcn(hObject, eventdata, handles)
% hObject handle to b1 (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 a21_Callback(hObject, eventdata, handles)
% hObject handle to a21 (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 a21 as text
% str2double(get(hObject,'String')) returns contents of a21 as a double
% --- Executes during object creation, after setting all properties.
function a21_CreateFcn(hObject, eventdata, handles)
% hObject handle to a21 (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 b20_Callback(hObject, eventdata, handles)
% hObject handle to b20 (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 b20 as text
% str2double(get(hObject,'String')) returns contents of b20 as a double
% --- Executes during object creation, after setting all properties.
function b20_CreateFcn(hObject, eventdata, handles)
% hObject handle to b20 (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 b21_Callback(hObject, eventdata, handles)
% hObject handle to b21 (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 b21 as text
% str2double(get(hObject,'String')) returns contents of b21 as a double
% --- Executes during object creation, after setting all properties.
function b21_CreateFcn(hObject, eventdata, handles)
% hObject handle to b21 (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 a11_Callback(hObject, eventdata, handles)
% hObject handle to a11 (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 a11 as text
% str2double(get(hObject,'String')) returns contents of a11 as a double
% --- Executes during object creation, after setting all properties.
function a11_CreateFcn(hObject, eventdata, handles)
% hObject handle to a11 (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 a12_Callback(hObject, eventdata, handles)
% hObject handle to a12 (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 a12 as text
% str2double(get(hObject,'String')) returns contents of a12 as a double
% --- Executes during object creation, after setting all properties.
function a12_CreateFcn(hObject, eventdata, handles)
% hObject handle to a12 (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 b11_Callback(hObject, eventdata, handles)
% hObject handle to a21 (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 a21 as text
% str2double(get(hObject,'String')) returns contents of a21 as a double
% --- Executes during object creation, after setting all properties.
function b11_CreateFcn(hObject, eventdata, handles)
% hObject handle to a21 (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 a22_Callback(hObject, eventdata, handles)
% hObject handle to a22 (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 a22 as text
% str2double(get(hObject,'String')) returns contents of a22 as a double
% --- Executes during object creation, after setting all properties.
function a22_CreateFcn(hObject, eventdata, handles)
% hObject handle to a22 (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 pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x_audio;
[NamaFile,NamaPath] = uigetfile({'*.wav'},'Muat File Wav');
[x,Fs] = wavread([NamaPath '/' NamaFile]);
handles.x = x ./ max(abs(x));
handles.Fs = Fs;
axes(handles.axes2);
waktu = 0:1/Fs:(length(handles.x)-1)/Fs;
plot(waktu, handles.x,'linewidth',1,'color','r');
axis([0 max(waktu) -1 1]); title('Sinyal Audio');
axes(handles.axes3);
specgram(handles.x, 1024, handles.Fs);
title('Spektrum Sinyal');
handles.fileDimuat = 1;
handles.fileBerderau = 0;
handles.fileFinal = 0;
set(handles.FrekCuplik, 'String', num2str(Fs));
set(handles.N, 'String', num2str(length(handles.x)));
x_audio = handles.x;
guidata(hObject, handles);
function FrekCuplik_Callback(hObject, eventdata, handles)
% hObject handle to FrekCuplik (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 FrekCuplik as text
% str2double(get(hObject,'String')) returns contents of FrekCuplik as a double
% --- Executes during object creation, after setting all properties.
function FrekCuplik_CreateFcn(hObject, eventdata, handles)
% hObject handle to FrekCuplik (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 pushbutton13.
function pushbutton13_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton13 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if (handles.fileDimuat==1)
sound(handles.x, handles.Fs);
end
% --- Executes on button press in pushbutton14.
function pushbutton14_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton14 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global x_audio;
% Membaca semua koefisien tapis parallel
a11 = str2num(get(handles.a11,'String'));
a21 = str2num(get(handles.a21,'String'));
a12 = str2num(get(handles.a12,'String'));
a22 = str2num(get(handles.a22,'String'));
c0 = str2num(get(handles.c0,'String'));
b10 = str2num(get(handles.b10,'String'));
b11 = str2num(get(handles.b11,'String'));
b20 = str2num(get(handles.b20,'String'));
b21 = str2num(get(handles.b21,'String'));
% Konversi dari PARALLEL ke DIRECT
B = [b10 b11; b20 b21];
A = [1 a11 a12; 1 a21 a22];
[b,a] = par2dir(c0,B,A);
% Menghitung Hasil Penapisan
y = filter(b,a,x_audio);
axes(handles.axes2);
t = 0:length(y)-1; %vektor indeks
plot(t,y,'linewidth',1,'color','r');title('Keluaran Tapis')
axes(handles.axes3)
specgram(y, 1024, handles.Fs);
title('Spektrum Sinyal');
handles.fileDimuat = 1;
handles.x=y;
guidata(hObject, handles);
function b0_Callback(hObject, eventdata, handles)
% hObject handle to b0 (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 b0 as text
% str2double(get(hObject,'String')) returns contents of b0 as a double
% --- Executes during object creation, after setting all properties.
function b0_CreateFcn(hObject, eventdata, handles)
% hObject handle to b0 (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 b10_Callback(hObject, eventdata, handles)
% hObject handle to b10 (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 b10 as text
% str2double(get(hObject,'String')) returns contents of b10 as a double
% --- Executes during object creation, after setting all properties.
function b10_CreateFcn(hObject, eventdata, handles)
% hObject handle to b10 (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
No comments:
Post a Comment