Top Banner
http://www.encodemaster.BlogSpot.com/ http://www.encodemaster.com/ Project Report Signal and Systems Group: Asad Arshad Awan (F-3725) Submitted To: Engr XYZ
23

Scientific Calculator in GUI MATLAB

Mar 29, 2023

Download

Documents

حسن علی
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scientific Calculator in GUI MATLAB

http://www.encodemaster.BlogSpot.com/http://www.encodemaster.com/

Project ReportSignal and Systems

Group: Asad Arshad Awan (F-3725)

Submitted To:Engr XYZ

Page 2: Scientific Calculator in GUI MATLAB

Scientific Calculator in GUI

We are going to make a GUI based scientific Calculator in matlab.A graphical user interface (GUI) is a pictorial interface to aprogram. A good GUI can make programs easier to use by providingthem with a consistent appearance and with intuitive controlslike pushbuttons, list boxes, sliders, menus, and so forth. TheGUI should behave in an understandable and predictable manner, sothat a user knows what to expect when he or she performs anaction. For example, when a mouse click occurs on a pushbutton,the GUI should initiate the action described on the label of thebutton.

How a Graphical User Interface Works

A graphical user interface provides the user with a familiarenvironment in which to work. This environment containspushbuttons, toggle buttons, lists, menus, text boxes, and soforth, all of which are already familiar to the user, so that heor she can concentrate on using the application rather than onthe mechanics involved in doing things. However, GUIs are harderfor the programmer because a GUI-based program must be preparedfor mouse clicks (or possibly keyboard input) for any GUI elementat any time. Such inputs are known as events, and a program thatresponds to events is said to be event driven. The three principalelements required to create a MATLAB Graphical User Interface are

1. Components. Each item on a MATLAB GUI (pushbuttons, labels,edit boxes, etc.) is a graphical component. The types ofcomponents include graphical controls (pushbuttons, edit boxes,lists, sliders, etc.), static elements (frames and text strings),menus, and axes. Graphical controls and static elements arecreated by the function uicontrol, and menus are created by thefunctions uimenu and uicontextmenu. Axes, which are used todisplay graphical data, are created by the function axes.

Page 3: Scientific Calculator in GUI MATLAB

2. Figures. The components of a GUI must be arranged within afigure, which is a window on the computer screen. In the past,figures have been created automatically whenever we have plotteddata. However, empty figures can be created with the functionfigure and can be used to hold any combination of components.3. Callbacks. Finally, there must be some way to perform anaction if a user clicks a mouse on a button or types informationon a keyboard. A mouse click or a key press is an event, and theMATLAB program must respond to each event if the program is toperform its function.

Scientific Calculator: This calculator supports advanced mathematical functions which are useful for scientific calculations. Trigonometric, logarithmic and exponential functions, floating point arithmetic, complex numbers and supportfor large numbers is integrated. Most common functions are accessible by buttons with mouse over usage tips.

We will have some Common Scientific operation in our calculator:

Page 4: Scientific Calculator in GUI MATLAB

Trigonometric Functions

Function Description  Function Descriptionsin() sine  asin() inverse sinecos() cosine  acos() inverse cosinetan() tangent  atan() inverse tangent

cot() cotangent ie cos()/sin()  acot() inverse cotanget ie

atan(1/x)

sec() secant ie 1/cos()  asec() inverse secant ie acos(1/x)

csc() cosecant ie 1/sin()  acsc() inverse cosecant ie asin(1/x)

Hyperbolic functions

sinh() hyperbolic sine  asinh() inverse hyperbolic sine

cosh() hyperbolic cosine  acosh() inverse hyperbolic cosine

tanh() hyperbolic tangent  atanh() inverse hyperbolic tangent

coth() hyperbolic cotangent  acoth() inverse hyperbolic cotangent

sech() hyperbolic secant  asech() inverse hyperbolic secant

csch() hyperbolic cosecant  acsch() inverse hyperbolic cosecant

General Functions

sqrt() square root  exp(x) e to the power xabs() absolute value  log() base 10 logarithmfact() factorial  ln() natural logarithm

 

Page 5: Scientific Calculator in GUI MATLAB

Arithmetic Functions

+ Addition- Subtraction/ Division * Multiplication

Note: Mat-lab files are attached in email... Thanks

Page 6: Scientific Calculator in GUI MATLAB

Code:function varargout = calculator2(varargin)% CALCULATOR2 M-file for calculator2.fig% CALCULATOR2, by itself, creates a new CALCULATOR2 or raises theexisting% singleton*.% www.EncodeMaster.com% www.EncodeMaster.BlogSpot.com% H = CALCULATOR2 returns the handle to a new CALCULATOR2 or the handle to% the existing singleton*.%% CALCULATOR2('CALLBACK',hObject,eventData,handles,...) calls thelocal% function named CALLBACK in CALCULATOR2.M with the given input arguments.%% CALCULATOR2('Property','Value',...) creates a new CALCULATOR2 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before calculator_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to calculator2_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

% Copyright 2002-2003 The MathWorks, Inc.

% Edit the above text to modify the response to help calculator2

% Last Modified by GUIDE v2.5 17-Dec-2012 20:15:53

Page 7: Scientific Calculator in GUI MATLAB

% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @calculator2_OpeningFcn, ... 'gui_OutputFcn', @calculator2_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 calculator2 is made visible.function calculator2_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 calculator2 (see VARARGIN)

% Choose default command line output for calculator2handles.output = hObject;

% Update handles structureguidata(hObject, handles);

% UIWAIT makes calculator2 wait for user response (see UIRESUME)% uiwait(handles.figure1);global airth logicset(handles.text1,'String','0.');airth=0;logic=0;

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

Page 8: Scientific Calculator in GUI MATLAB

function varargout = calculator2_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 structurevarargout{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)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','1') ;elsetextString =strcat(textString,'1');set(handles.text1,'String',textString)

endairth=0;

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','2') ;elsetextString =strcat(textString,'2');set(handles.text1,'String',textString)

end

Page 9: Scientific Calculator in GUI MATLAB

airth=0;

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','3') ;elsetextString =strcat(textString,'3');set(handles.text1,'String',textString)

endairth=0;

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','+') ;elsetextString =strcat(textString,'+');set(handles.text1,'String',textString)

endairth=0;

% --- 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)textString = get(handles.text1,'String');ans =eval(textString);

Page 10: Scientific Calculator in GUI MATLAB

set(handles.text1,'String',ans)

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','0') ;elsetextString =strcat(textString,'0');set(handles.text1,'String',textString)

endairth=0;

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','.') ;elsetextString =strcat(textString,'.');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton8.

Page 11: Scientific Calculator in GUI MATLAB

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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','4') ;elsetextString =strcat(textString,'4');set(handles.text1,'String',textString)

endairth=0;

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','5') ;elsetextString =strcat(textString,'5');set(handles.text1,'String',textString)

endairth=0;

% --- 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)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','6') ;

Page 12: Scientific Calculator in GUI MATLAB

elsetextString =strcat(textString,'6');set(handles.text1,'String',textString)

endairth=0;

% --- 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)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','9') ;elsetextString =strcat(textString,'9');set(handles.text1,'String',textString)

endairth=0;

% --- 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 airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','8') ;elsetextString =strcat(textString,'8');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton13.function pushbutton13_Callback(hObject, eventdata, handles)

Page 13: Scientific Calculator in GUI MATLAB

% 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)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','7') ;elsetextString =strcat(textString,'7');set(handles.text1,'String',textString)

endairth=0;

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

set(handles.text1,'String','0.') ;

% --- Executes on button press in pushbutton15.function pushbutton15_Callback(hObject, eventdata, handles)% hObject handle to pushbutton15 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','-') ;elsetextString =strcat(textString,'-');set(handles.text1,'String',textString)

endairth=0;

Page 14: Scientific Calculator in GUI MATLAB

% --- Executes on button press in pushbutton16.function pushbutton16_Callback(hObject, eventdata, handles)% hObject handle to pushbutton16 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','*') ;elsetextString =strcat(textString,'*');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton17.function pushbutton17_Callback(hObject, eventdata, handles)% hObject handle to pushbutton17 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','/') ;elsetextString =strcat(textString,'/');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton18.function pushbutton18_Callback(hObject, eventdata, handles)% hObject handle to pushbutton18 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

Page 15: Scientific Calculator in GUI MATLAB

global logictextString = get(handles.text1,'String'); switch logic case 0if(strcmp(textString,'0.')==1) set(handles.text1,'String','sin') ;elsetextString =strcat(textString,'sin');set(handles.text1,'String',textString) endcase 1if(strcmp(textString,'0.')==1) set(handles.text1,'String','asin') ;elsetextString =strcat(textString,'asin');set(handles.text1,'String',textString)end end

% --- Executes on button press in pushbutton19.function pushbutton19_Callback(hObject, eventdata, handles)% hObject handle to pushbutton19 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','sqrt') ;elsetextString =strcat(textString,'sqrt');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton20.function pushbutton20_Callback(hObject, eventdata, handles)% hObject handle to pushbutton20 (see GCBO)

Page 16: Scientific Calculator in GUI MATLAB

% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','(') ;elsetextString =strcat(textString,'(');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton21.function pushbutton21_Callback(hObject, eventdata, handles)% hObject handle to pushbutton21 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String',')') ;elsetextString =strcat(textString,')');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton22.function pushbutton22_Callback(hObject, eventdata, handles)% hObject handle to pushbutton22 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0)

Page 17: Scientific Calculator in GUI MATLAB

set(handles.text1,'String','pi') ;elsetextString =strcat(textString,'pi');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton23.function pushbutton23_Callback(hObject, eventdata, handles)% hObject handle to pushbutton23 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','exp') ;elsetextString =strcat(textString,'exp');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton25.function pushbutton25_Callback(hObject, eventdata, handles)% hObject handle to pushbutton25 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global logictextString = get(handles.text1,'String'); switch logic case 0if(strcmp(textString,'0.')==1) set(handles.text1,'String','cos') ;elsetextString =strcat(textString,'cos');set(handles.text1,'String',textString) end

Page 18: Scientific Calculator in GUI MATLAB

case 1if(strcmp(textString,'0.')==1) set(handles.text1,'String','acos') ;elsetextString =strcat(textString,'acos');set(handles.text1,'String',textString)end end

% --- Executes on button press in pushbutton26.function pushbutton26_Callback(hObject, eventdata, handles)% hObject handle to pushbutton26 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

global logictextString = get(handles.text1,'String'); switch logic case 0if(strcmp(textString,'0.')==1) set(handles.text1,'String','tan') ;elsetextString =strcat(textString,'tan');set(handles.text1,'String',textString) endcase 1if(strcmp(textString,'0.')==1) set(handles.text1,'String','atan') ;elsetextString =strcat(textString,'atan');set(handles.text1,'String',textString)end end

% --- Executes on button press in pushbutton27.function pushbutton27_Callback(hObject, eventdata, handles)% hObject handle to pushbutton27 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

Page 19: Scientific Calculator in GUI MATLAB

global logictextString = get(handles.text1,'String'); switch logic case 0if(strcmp(textString,'0.')==1) set(handles.text1,'String','log') ;elsetextString =strcat(textString,'log');set(handles.text1,'String',textString)end case 1if(strcmp(textString,'0.')==1) set(handles.text1,'String','log10') ;elsetextString =strcat(textString,'log10');set(handles.text1,'String',textString)end end

% --- Executes on button press in pushbutton28.function pushbutton28_Callback(hObject, eventdata, handles)% hObject handle to pushbutton28 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airth logic

logic=1;

% --- Executes on button press in pushbutton29.function pushbutton29_Callback(hObject, eventdata, handles)% hObject handle to pushbutton29 (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 pushbutton30.function pushbutton30_Callback(hObject, eventdata, handles)% hObject handle to pushbutton30 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB

Page 20: Scientific Calculator in GUI MATLAB

% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','^') ;elsetextString =strcat(textString,'^');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton31.function pushbutton31_Callback(hObject, eventdata, handles)% hObject handle to pushbutton31 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','factorial') ;elsetextString =strcat(textString,'factorial');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton32.function pushbutton32_Callback(hObject, eventdata, handles)% hObject handle to pushbutton32 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)textString = get(handles.text1,'String');if(strcmp(textString,'0.')==1) set(handles.text1,'String','0.') ;else

Page 21: Scientific Calculator in GUI MATLAB

n = strread(textString, '%f');n=0-n;set(handles.text1,'String',n)end

% --- Executes on button press in pushbutton33.function pushbutton33_Callback(hObject, eventdata, handles)% hObject handle to pushbutton33 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','sinh') ;elsetextString =strcat(textString,'sinh');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton34.function pushbutton34_Callback(hObject, eventdata, handles)% hObject handle to pushbutton34 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','cosh') ;elsetextString =strcat(textString,'cosh');set(handles.text1,'String',textString)

endairth=0;

Page 22: Scientific Calculator in GUI MATLAB

% --- Executes on button press in pushbutton35.function pushbutton35_Callback(hObject, eventdata, handles)% hObject handle to pushbutton35 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global airthtextString = get(handles.text1,'String');

if(strcmp(textString,'0.')==1)&(airth==0) set(handles.text1,'String','tanh') ;elsetextString =strcat(textString,'tanh');set(handles.text1,'String',textString)

endairth=0;

% --- Executes on button press in pushbutton36.function pushbutton36_Callback(hObject, eventdata, handles)% hObject handle to pushbutton36 (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 pushbutton37.function pushbutton37_Callback(hObject, eventdata, handles)% hObject handle to pushbutton37 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)

function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (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 edit1 as text

Page 23: Scientific Calculator in GUI MATLAB

% str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (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 edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (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 edit2 as text% str2double(get(hObject,'String')) returns contents of edit2 as a double

% --- Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (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