Code covered by the BSD License  

Highlights from
Graphical Calculator

image thumbnail

Graphical Calculator

by

 

addition,subtraction,plot,stem, permutation,combination.

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

% Last Modified by GUIDE v2.5 08-Jun-2012 03:07:13

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

% Choose default command line output for calculator
handles.output = hObject;
X=imread('iiui.jpg');
imshow(X,'parent',handles.logo)
set(handles.date,'String',date)
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes calculator wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = calculator_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 no1.
function no1_Callback(hObject, eventdata, handles)
% hObject    handle to no1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

a0=get(handles.display,'String');
b0=strcat(a0,'1');
set(handles.display,'String',b0);


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


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

a0=get(handles.display,'String');
b0=strcat(a0,'4');
set(handles.display,'String',b0);
% --- Executes on button press in no7.
function no7_Callback(hObject, eventdata, handles)
% hObject    handle to no7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'7');
set(handles.display,'String',b0);

% --- Executes on button press in no0.
function no0_Callback(hObject, eventdata, handles)
% hObject    handle to no0 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'0');
set(handles.display,'String',b0);

% --- Executes on button press in cos.
function cos_Callback(hObject, eventdata, handles)
% hObject    handle to cos (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'cosd(');
set(handles.display,'String',b0);

% --- Executes on button press in no2.
function no2_Callback(hObject, eventdata, handles)
% hObject    handle to no2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'2');
set(handles.display,'String',b0);

% --- Executes on button press in no5.
function no5_Callback(hObject, eventdata, handles)
% hObject    handle to no5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'5');
set(handles.display,'String',b0);

% --- Executes on button press in no8.
function no8_Callback(hObject, eventdata, handles)
% hObject    handle to no8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'8');
set(handles.display,'String',b0);

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

a0=get(handles.display,'String');
b0=strcat(a0,'.');
set(handles.display,'String',b0);
% --- Executes on button press in sin.
function sin_Callback(hObject, eventdata, handles)
% hObject    handle to sin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'sind(');
set(handles.display,'String',b0);

% --- Executes on button press in no3.
function no3_Callback(hObject, eventdata, handles)
% hObject    handle to no3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'3');
set(handles.display,'String',b0);

% --- Executes on button press in no6.
function no6_Callback(hObject, eventdata, handles)
% hObject    handle to no6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'6');
set(handles.display,'String',b0);

% --- Executes on button press in no9.
function no9_Callback(hObject, eventdata, handles)
% hObject    handle to no9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'9');
set(handles.display,'String',b0);

% --- Executes on button press in equal.
function equal_Callback(hObject, eventdata, handles)
% hObject    handle to equal (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%set(handles.result,'String',out);

ri=get(handles.display,'String');
ro=eval(ri);
set(handles.result,'String',ro);


% set(handles.display,'String','');

% --- Executes on button press in tan.
function tan_Callback(hObject, eventdata, handles)
% hObject    handle to tan (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'tand(');
set(handles.display,'String',b0);

% --- Executes on button press in add.
function add_Callback(hObject, eventdata, handles)
% hObject    handle to add (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'+');
set(handles.display,'String',b0);



% --- Executes on button press in sub.
function sub_Callback(hObject, eventdata, handles)
% hObject    handle to sub (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'-');
set(handles.display,'String',b0);

% --- Executes on button press in multiply.
function multiply_Callback(hObject, eventdata, handles)
% hObject    handle to multiply (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'*');
set(handles.display,'String',b0);

% --- Executes on button press in divide.
function divide_Callback(hObject, eventdata, handles)
% hObject    handle to divide (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'/');
set(handles.display,'String',b0);

% --- Executes on button press in clear.
function clear_Callback(hObject, eventdata, handles)
% hObject    handle to clear (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
set(handles.display,'String','');
set(handles.result,'String','');
cla(handles.graph);
set(handles.domain,'String','');


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


% --- Executes during object creation, after setting all properties.
function display_CreateFcn(hObject, eventdata, handles)
% hObject    handle to display (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 exit.
function exit_Callback(hObject, eventdata, handles)
% hObject    handle to exit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
delete(gcf);


% --- Executes on button press in br.
function br_Callback(hObject, eventdata, handles)
% hObject    handle to br (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,')');
set(handles.display,'String',b0);


% --- Executes on key press with focus on equal and none of its controls.
function equal_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to equal (see GCBO)
% eventdata  structure with the following fields (see UICONTROL)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)

% --- Executes on button press in ans.
function ans_Callback(hObject, eventdata, handles)
% hObject    handle to ans (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
r1=get(handles.result,'String');
if(isempty(r1))
a0=get(handles.display,'String');
ri=get(handles.display,'String');
ro=eval(ri);
set(handles.result,'String',ro);
else
get(handles.display,'String');
b0=strcat(a0,'Ans');
set(handles.display,'String',b0);
end


% --- Executes on button press in factorial.
function factorial_Callback(hObject, eventdata, handles)
% hObject    handle to factorial (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'factorial()');
set(handles.display,'String',b0);

% --- Executes on button press in plotf.
function plotf_Callback(hObject, eventdata, handles)
% hObject    handle to plotf (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
t=str2num(get(handles.domain,'String'));
a=eval(get(handles.display,'String'));
axes(handles.graph);
plot(t,a);


% --- Executes on button press in nCr.
function nCr_Callback(hObject, eventdata, handles)
% hObject    handle to nCr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'C( , )');
set(handles.display,'String',b0);

% --- Executes on button press in nPr.
function nPr_Callback(hObject, eventdata, handles)
% hObject    handle to nPr (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'P( , )');
set(handles.display,'String',b0);


% --- Executes on button press in bl.
function bl_Callback(hObject, eventdata, handles)
% hObject    handle to bl (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'(');
set(handles.display,'String',b0);

% --- Executes on button press in ix.
function ix_Callback(hObject, eventdata, handles)
% hObject    handle to ix (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.result,'String');
b0=eval(a0);
c0=1/b0;
set(handles.result,'String',c0);

% --- Executes on button press in acosd.
function acosd_Callback(hObject, eventdata, handles)
% hObject    handle to acosd (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'acosd(');
set(handles.display,'String',b0);

% --- Executes on button press in asind.
function asind_Callback(hObject, eventdata, handles)
% hObject    handle to asind (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'asind(');
set(handles.display,'String',b0);

% --- Executes on button press in atand.
function atand_Callback(hObject, eventdata, handles)
% hObject    handle to atand (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=get(handles.display,'String');
b0=strcat(a0,'atand(');
set(handles.display,'String',b0);



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


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


% --- Executes on button press in dec2binary.



% --- Executes on button press in dec2hex.
function dec2bin_Callback(hObject, eventdata, handles)
% hObject    handle to dec2bin (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=str2num(get(handles.result,'String'));
b0=dec2base(a0,2);
set(handles.result,'String',b0);


% --- Executes on button press in dec2oct.
function dec2oct_Callback(hObject, eventdata, handles)
% hObject    handle to dec2oct (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=str2num(get(handles.result,'String'));
b0=dec2base(a0,8);
set(handles.result,'String',b0);


% --- Executes on button press in dec2hex.
function dec2hex_Callback(hObject, eventdata, handles)
% hObject    handle to dec2hex (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
a0=str2num(get(handles.result,'String'));
b0=dec2base(a0,16);
set(handles.result,'String',b0);


% --- Executes on button press in disctrete.
function disctrete_Callback(hObject, eventdata, handles)
% hObject    handle to disctrete (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
t=str2num(get(handles.domain,'String'));
a=eval(get(handles.display,'String'));
axes(handles.graph);
stem(t,a);

Contact us