Sunteți pe pagina 1din 8

Contoh tampilan kalkulator dengan matlab 2008

Program didalam nya


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

% --- Outputs from this function are returned to the command line. function varargout = Calkulatorr_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 tbenter. function tbenter_Callback(hObject, eventdata, handles) % hObject handle to tbenter (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.txthasil,'String'); ans =eval(textString); set(handles.txthasil,'String',ans)

% --- Executes on button press in tbplus. function tbplus_Callback(hObject, eventdata, handles) % hObject handle to tbplus (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.txthasil,'String'); textString =strcat(textString,'+'); set(handles.txthasil,'String',textString)

% --- Executes on button press in tbmin. function tbmin_Callback(hObject, eventdata, handles) % hObject handle to tbmin (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.txthasil,'String'); textString =strcat(textString,'-'); set(handles.txthasil,'String',textString)

% --- Executes on button press in tbkali. function tbkali_Callback(hObject, eventdata, handles) % hObject handle to tbkali (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.txthasil,'String'); textString =strcat(textString,'*'); set(handles.txthasil,'String',textString) % --- Executes on button press in tbbagi. function tbbagi_Callback(hObject, eventdata, handles) % hObject handle to tbbagi (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.txthasil,'String'); textString =strcat(textString,'/'); set(handles.txthasil,'String',textString) % --- Executes on button press in tb0. function tb0_Callback(hObject, eventdata, handles)

% hObject % eventdata % handles global jj textString =

handle to tb0 (see GCBO) reserved - to be defined in a future version of MATLAB structure with handles and user data (see GUIDATA) get(handles.txthasil,'String');

if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','0') ; else textString =strcat(textString,'0'); set(handles.txthasil,'String',textString); end jj=0; % --- Executes on button press in tb1. function tb1_Callback(hObject, eventdata, handles) % hObject handle to tb1 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','1') ; else textString =strcat(textString,'1'); set(handles.txthasil,'String',textString); end jj=0; % --- Executes on button press in tb2. function tb2_Callback(hObject, eventdata, handles) % hObject handle to tb2 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','2') ; else textString =strcat(textString,'2'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb3. function tb3_Callback(hObject, eventdata, handles) % hObject handle to tb3 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','3') ; else textString =strcat(textString,'3'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb4. function tb4_Callback(hObject, eventdata, handles) % hObject handle to tb4 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','4') ; else textString =strcat(textString,'4'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb5. function tb5_Callback(hObject, eventdata, handles) % hObject handle to tb5 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','5') ; else textString =strcat(textString,'5'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb6. function tb6_Callback(hObject, eventdata, handles) % hObject handle to tb6 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','6') ;

else textString =strcat(textString,'6'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb7. function tb7_Callback(hObject, eventdata, handles) % hObject handle to tb7 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','7') ; else textString =strcat(textString,'7'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb8. function tb8_Callback(hObject, eventdata, handles) % hObject handle to tb8 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','8') ; else textString =strcat(textString,'8'); set(handles.txthasil,'String',textString) end jj=0; % --- Executes on button press in tb9. function tb9_Callback(hObject, eventdata, handles) % hObject handle to tb9 (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.txthasil,'String'); if(strcmp(textString,'0.')==1)&&(jj==0) set(handles.txthasil,'String','9') ; else textString =strcat(textString,'9'); set(handles.txthasil,'String',textString)

end jj=0;

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

function edit3_Callback(hObject, eventdata, handles) % hObject handle to edit3 (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 edit3 as text % str2double(get(hObject,'String')) returns contents of edit3 as a double

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

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

function txthasil_Callback(hObject, eventdata, handles) % hObject handle to txthasil (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 txthasil as text % str2double(get(hObject,'String')) returns contents of txthasil as a double

S-ar putea să vă placă și