Seting a pushbutton in a GUI
Show older comments
Hello,
I made a simple GUI with two editable text boxes and a pushbutton. I just knowing how the GUI comands works. At this moment i just wanna make an adder. I already know how to get the numbers typed in the text boxes and putting them into a variable. Now, i wanna set the pushbutton to run the program and adding the numbers. The problem is: i don't know how to set up the pushbutton to run the program. Please explain easily because i still don't understand so much about programming in Matlab. thank you very much !
Answers (1)
Paulo Silva
on 21 Feb 2011
function somar
fig=figure(1)
b1= uicontrol('Style','pushbutton',...
'String','Run Program',...
'Callback',@soma,...
'Position',[315,220,70,25]);
e1= uicontrol('Style','edit',...
'String','','Position',[315,180,70,25]);
e2= uicontrol('Style','edit',...
'String','','Position',[315,135,70,25]);
e3= uicontrol('Style','text',...
'String','','Position',[315,90,70,25]);
function soma(hObject,handles,eventdata)
set(e3,'String',str2num(get(e1,'String'))+str2num(get(e2,'String')))
end
end
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!