1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
function calculatrice
handles.fenetre = figure ('units','pixels',...
'Position',[500 200 800 600],...
'color',rand(1,3),...
'tag','fenetre');
handles.resultat = uicontrol('style','Text',...
'string','0',...
'fontsize',20,...
'units','pixels',...
'Position',[650 300 100 50 ],...
'tag','resultat');
handles.donnee1= uicontrol('style','edit',...
'string','0',...
'fontsize',20,...
'Units','pixels',...
'position',[50 300 100 50],...
'tag','donnee1');
handles.donnee2= uicontrol('style','edit',...
'string','0',...
'fontsize',20,...
'Units','pixels',...
'position',[300 300 100 50],...
'tag','donnee2');
handles.plus= uicontrol('style','Text',...
'string','+',...
'fontsize',20,...
'units','pixels',...
'Position',[175 300 100 35 ],...
'tag','+');
handles.equal= uicontrol('style','Text',...
'string','=',...
'fontsize',20,...
'units','pixels',...
'Position',[500 300 100 35 ],...
'tag','=');
handles.add= uicontrol('style','pushbutton',...
'string','Add',...
'fontsize',20,...
'Units','pixels',...
'position',[400 150 100 50],...
'tag','add',...
'callback',@addition);
guidata(handles.fenetre, handles);
function addition(objet,event)
handles = guidata(objet);
a=get(handles.donnee1,'string');
b=get(handles.donnee2,'string');
c= str2double(a) + str2double(b);
set(handles.resultat,'string',double2str(c));
guidata(objet, handles); |
Partager