You are on page 1of 11

SUMMATIVE ASSESSMENT

#3

Module 6: Graphical User Interface

Tan, Kim Nazareth S.

ECENUMEL – AL31

BSME – 201610354

Prof. JH Villaroel & Prof. PM Loresco


DATA & RESULTS
function varargout = scical(varargin)
% SCICAL MATLAB code for scical.fig
% SCICAL, by itself, creates a new SCICAL or raises the existing
% singleton*.
%
% H = SCICAL returns the handle to a new SCICAL or the handle to
% the existing singleton*.
%
% SCICAL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in SCICAL.M with the given input arguments.
%
% SCICAL('Property','Value',...) creates a new SCICAL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before scical_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to scical_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 scical

% Last Modified by GUIDE v2.5 18-Mar-2021 20:16:40

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @scical_OpeningFcn, ...
'gui_OutputFcn', @scical_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 scical is made visible.


function scical_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 scical (see VARARGIN)

% Choose default command line output for scical


handles.output = hObject;
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes scical wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = scical_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)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'1');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton2.


function pushbutton2_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'2');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton3.


function pushbutton3_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'3');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton4.


function pushbutton4_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'4');
%Set the string
set(handles.text2,'String',textString)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'6');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton8.


function pushbutton8_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'8');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton9.


function pushbutton9_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'9');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton5.


function pushbutton5_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'5');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton6.


function pushbutton7_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'7');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton10.


function pushbutton10_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'0');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in period_pushbotton.


function period_pushbotton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'.');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton12.


function pushbutton12_Callback(hObject, eventdata, handles)
textString = get(handles.text2,'String');
%strcmp(textString,'0.')
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','0.') ;
else
a = strread(textString, '%f');
a=0-a;
set(handles.text2,'String',a)
end

% --- Executes on button press in open_pushbutton.


function open_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'(');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in close_pushbutton.


function close_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,')');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in exp_pushbutton.


function exp_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to exp_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global shift
textString = get(handles.text2,'String');
switch shift
case 0
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','exp') ;
else
textString =strcat(textString,'exp');
set(handles.text2,'String',textString)
end

end

% --- Executes on button press in add_pushbutton.


function add_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'+');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in sub_pushbutton.


function sub_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'-');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in del_pushbutton.


function del_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to del_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

global jj
textString = get(handles.text2,'String');

if(strcmp(textString,'0.')==1)&(jj==0)
set(handles.text2,'String','0.') ;
else
ss=char(textString);
l=length(textString);
textString=ss(1:l-1);
set(handles.text2,'String',textString)

end
jj=0;

% --- Executes on button press in ac_pushbutton.


function ac_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to ac_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.text2,'String','');

% --- Executes on button press in mul_pushbutton.


function mul_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'*');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in div_pushbutton.


function div_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'/');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in sqrt_pushbutton.


function sqrt_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to sqrt_pushbutton (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 percent_pushbutton.


function percent_pushbutton_Callback(hObject, eventdata, handles)
%Get current string from the text display
textString = get(handles.text2,'String');
%Concantenate 1 to the end
textString = strcat(textString,'%');
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in equal_pushbutton.


function equal_pushbutton_Callback(hObject, eventdata, handles)
textString = get(handles.text2,'String');
%Evaluate in symbolic form
textString = eval(textString);
%Set the string
set(handles.text2,'String',textString)

% --- Executes on button press in pushbutton43.


function pushbutton43_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton43 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global shift
shift=0;

% --- Executes on button press in pushbutton44.


function pushbutton44_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton24 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global shift
textString = get(handles.text2,'String');
switch shift
case 0
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','atan(') ;
else
textString =strcat(textString,'atan(');
set(handles.text2,'String',textString)
end
case 1
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','tan(') ;
else
textString =strcat(textString,'tan(');
set(handles.text2,'String',textString)
end
end

% --- Executes on button press in pushbutton45.


function pushbutton45_Callback(hObject, eventdata, handles)
global shift
textString = get(handles.text2,'String');
switch shift
case 0
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','log10(') ;
else
textString =strcat(textString,'log10(');
set(handles.text2,'String',textString)
end
case 1
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','log(') ;
else
textString =strcat(textString,'log(');
set(handles.text2,'String',textString)
end
end

% --- Executes on button press in pushbutton46.


function pushbutton46_Callback(hObject, eventdata, handles)
global shift
textString = get(handles.text2,'String');
switch shift
case 0
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','asin(') ;
else
textString =strcat(textString,'asin(');
set(handles.text2,'String',textString)
end
case 1
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','sin(') ;
else
textString =strcat(textString,'sin(');
set(handles.text2,'String',textString)
end
end

% --- Executes on button press in pushbutton47.


function pushbutton47_Callback(hObject, eventdata, handles)
global shift
textString = get(handles.text2,'String');
switch shift
case 0
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','acos(') ;
else
textString =strcat(textString,'acos(');
set(handles.text2,'String',textString)
end
case 1
if(strcmp(textString,'0.')==1)
set(handles.text2,'String','cos(') ;
else
textString =strcat(textString,'cos(');
set(handles.text2,'String',textString)
end
end
Analysis
One of the analysis I made while doing this summative assessment is that the GUI feature is a
really useful tool and vast uses. You can make almost any basic software you can think of. Honestly, I am
having a hard time while doing this basic scientific calculator because there is a lot of commands and
codes I should know before doing this activity. Although it may be difficult, I also found it interesting and
amusing to see if I can really make a basic scientific calculator. The time I finished my software, I find it
very satisfying to have it working. I also did a lot of trial and errors while making this activity, because of
that, I learned a lot of stuff while experimenting.
Conclusion
In conclusion, I learned how to make a basic scientific calculator. Learning new things and new
techniques on creating a GUI (Graphical User Interface) is a very handy and useful skill to have as an
engineer. By actually creating a basic scientific calculator, this made me realize of all the unlimited
possibilities you can do if you master GUI. One can create any basic software he/she can think of.
Overall, this activity is a very informative and very inspiring activity.

You might also like