You are on page 1of 8

A.

Listing Progam MatLab


function varargout = achmaddzulfikar(varargin) % ACHMADDZULFIKAR M-file for achmaddzulfikar.fig % ACHMADDZULFIKAR, by itself, creates a new ACHMADDZULFIKAR or raises the existing % singleton*. % % H = ACHMADDZULFIKAR returns the handle to a new ACHMADDZULFIKAR or the handle to % the existing singleton*. % % ACHMADDZULFIKAR('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in ACHMADDZULFIKAR.M with the given input arguments. % % ACHMADDZULFIKAR('Property','Value',...) creates a new ACHMADDZULFIKAR or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before achmaddzulfikar_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to achmaddzulfikar_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 achmaddzulfikar % Last Modified by GUIDE v2.5 29-Jan-2012 23:26:55 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @achmaddzulfikar_OpeningFcn, ... 'gui_OutputFcn', @achmaddzulfikar_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 achmaddzulfikar is made visible. function achmaddzulfikar_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 achmaddzulfikar (see VARARGIN) % Choose default command line output for achmaddzulfikar handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes achmaddzulfikar wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line. function varargout = achmaddzulfikar_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) % Hint: get(hObject,'Value') returns toggle state of Pushbutton1

% --- Executes on selection change in mode. function mode_Callback(hObject, eventdata, handles) % hObject handle to mode (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 mode contents as cell array % contents{get(hObject,'Value')} returns selected item from mode

% --- Executes during object creation, after setting all properties. function mode_CreateFcn(hObject, eventdata, handles) % hObject handle to mode (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles empty - handles not created until after all CreateFcns called % Hint: popupmenu controls usually have a white background on Windows. % See ISPC and COMPUTER. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white'); end

% --- Executes on button press in texit. function texit_Callback(hObject, eventdata, handles) % hObject handle to texit (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) close % Hint: get(hObject,'Value') returns toggle state of texit

% --- Executes on button press in togglebutton4. function togglebutton4_Callback(hObject, eventdata, handles) % hObject handle to togglebutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) N = 8; bit_stream = round(rand(1,N)); f = 3; fs = 100; a1 = 0;

a2 = 1; t = 0: 1/fs : 1; time = []; ASK_signal = []; Digital_signal = []; for ii = 1: 1: length(bit_stream) ASK_signal = [ASK_signal (bit_stream(ii)==0)*... sin(2*pi*f*t*a1) + (bit_stream(ii)==1)*sin(2*pi*f*t*a2)]; Digital_signal = [Digital_signal (bit_stream(ii)==0)*... zeros(1,length(t)) + (bit_stream(ii)==1)*ones(1,length(t))]; time = [time t]; t = t + 1; end subplot(2,1,1); plot(time,ASK_signal,'g','LineWidth',2); xlabel('Time'); ylabel('Amplitude'); title('ASK (Amplitude Shift Keying)'); axis([0 time(end) -1.5 1.5]); grid on; subplot(2,1,2); plot(time,Digital_signal,'b','LineWidth',2); xlabel('Time'); ylabel('Amplitude'); title('Digital Signal'); axis([0 time(end) -0.5 1.5]); grid on; % Hint: get(hObject,'Value') returns toggle state of togglebutton4

% --- Executes on button press in togglebutton5. function togglebutton5_Callback(hObject, eventdata, handles) % hObject handle to togglebutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) N = 8; bit_stream = round(rand(1,N)); f = 3; fs = 100; t = 0: 1/fs : 1; time = []; FSK_signal = []; Digital_signal = [];

for ii = 1: 1: length(bit_stream) FSK_signal = [FSK_signal (bit_stream(ii)==0)*... sin(2*pi*f*t*0.5) + (bit_stream(ii)==1)*sin(2*pi*f*t*(3/2))]; Digital_signal = [Digital_signal (bit_stream(ii)==0)*... zeros(1,length(t)) + (bit_stream(ii)==1)*ones(1,length(t))]; time = [time t]; t = t + 1; end subplot(2,1,1); plot(time,FSK_signal,'y','LineWidth',2); xlabel('Time'); ylabel('Amplitude'); title('FSK (Frequency Shift Keying)'); axis([0 time(end) -1.5 1.5]); grid on; subplot(2,1,2); plot(time,Digital_signal,'b','LineWidth',2); xlabel('Time'); ylabel('Amplitude'); title('Digital Signal'); axis([0 time(end) -0.5 1.5]); grid on; % Hint: get(hObject,'Value') returns toggle state of togglebutton5

% --- Executes on button press in togglebutton6. function togglebutton6_Callback(hObject, eventdata, handles) % hObject handle to togglebutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) N = 8; bit_stream = round(rand(1,N)); p1 = 0; p2 = pi; f = 3; fs = 100; t = 0: 1/fs : 1; time = []; PSK_signal = []; Digital_signal = []; for ii = 1: 1: length(bit_stream) PSK_signal = [PSK_signal (bit_stream(ii)==0)*... sin(2*pi*f*t + p1)+(bit_stream(ii)==1)*sin(2*pi*f*t + p2)];

Digital_signal = [Digital_signal (bit_stream(ii)==0)*... zeros(1,length(t)) + (bit_stream(ii)==1)*ones(1,length(t))]; time = [time t]; t = t + 1; end subplot(2,1,1); plot(time,PSK_signal,'r','LineWidth',2); xlabel('Time'); ylabel('Amplitude'); title('PSK (Phase Shift Keying)'); axis([0 time(end) -1.5 1.5]); grid on; subplot(2,1,2); plot(time,Digital_signal,'b','LineWidth',2); xlabel('Time'); ylabel('Amplitude'); title('Digital Signal'); axis([0 time(end) -0.5 1.5]); grid on;

B. Hasil

Tampilan Utama

Tampilan ASK

Tampilan FSK

Tampilan PSK

You might also like