You are on page 1of 4

BASHARAT KHATTAK CLASS #37

TO SIR HAIDER ZAMAN ASSIGNMENT #02

TO PLOT THE SINE GRAPH BY CHANGING ITS AMPLITUDE, FREQUENCY &


PHASE.
function varargout = basharat(varargin)
% BASHARAT MATLAB code for basharat.fig
%
BASHARAT, by itself, creates a new BASHARAT or raises the existing
%
singleton*.
%
%
H = BASHARAT returns the handle to a new BASHARAT or the handle to
%
the existing singleton*.
%
%
BASHARAT('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in BASHARAT.M with the given input arguments.
%
%
BASHARAT('Property','Value',...) creates a new BASHARAT or raises the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before basharat_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to basharat_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 basharat
% Last Modified by GUIDE v2.5 12-Sep-2013 23:19:25
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @basharat_OpeningFcn, ...
'gui_OutputFcn', @basharat_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 basharat is made visible.


function basharat_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 basharat (see VARARGIN)
set(handles.freq,'string','freq');
set(handles.amp,'string','amp');
set(handles.phase,'string','phase');
set(handles.run,'string','run');
% Choose default command line output for basharat
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes basharat wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = basharat_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 run.


function run_Callback(hObject, eventdata, handles)
% hObject
handle to run (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
t=0:0.1:5;
freq_Callback(hObject, eventdata, handles)

freq=get(handles.freq,'string');
freq1=str2double(freq);
amp_Callback(hObject, eventdata, handles)
amp=get(handles.amp,'string');
amp1=str2double(amp);
phase_Callback(hObject, eventdata, handles)
phase=get(handles.phase,'string');
phase1=str2double(phase);
y=amp1*sin(2*pi*freq1*t-phase1);
plot(t,y);

function freq_Callback(hObject, eventdata, handles)


% hObject
handle to freq (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 freq as text
%
str2double(get(hObject,'String')) returns contents of freq as a
double
freq=get(handles.freq,'string');
freq1=str2double(freq);
% --- Executes during object creation, after setting all properties.
function freq_CreateFcn(hObject, eventdata, handles)
% hObject
handle to freq (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 amp_Callback(hObject, eventdata, handles)


% hObject
handle to amp (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 amp as text
%
str2double(get(hObject,'String')) returns contents of amp as a double
amp=get(handles.amp,'string');
amp1=str2double(amp);

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


function amp_CreateFcn(hObject, eventdata, handles)
% hObject
handle to amp (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 phase_Callback(hObject, eventdata, handles)

% hObject
% eventdata
% handles

handle to phase (see GCBO)


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

% Hints: get(hObject,'String') returns contents of phase as text


%
str2double(get(hObject,'String')) returns contents of phase as a
double
phase=get(handles.phase,'string');
phase1=str2double(phase);

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


function phase_CreateFcn(hObject, eventdata, handles)
% hObject
handle to phase (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

You might also like