Reputation: 105
I am just a beginner with MATLAB GUIs and just want to know simple ways to do this.
I have four widgets: 2 list uicontrol
s, 1 push button uicontrol
s, and 1 static text uicontrol
.
function pushbutton1_Callback(hObject, eventdata, handles)
x =get(handles.popupmenu1, 'Value') % getting the value from the popupmenu
% doing something with it
y=get(handles.popupmenu2, 'Value') % getting the value and processing it
% doing something with it
total=x+y
set(handles.text1, 'String', num2str(total)) % set to total...but
% I really want it to be a string with a total. like 'Your total is %s', total
Can you please help me set the text string?
Upvotes: 1
Views: 82
Reputation: 13876
Something like that should do:
str = sprintf('your total is %s', num2str(total)); % assuming total is a number, not a string
set(handles.statictext1, 'String', str); % replace handles.statictext1 by whatever the handle your static text box is
Upvotes: 2