[英]passing values between uicontrols
我只是MATLAB GUI的初學者,只想知道執行此操作的簡單方法。
我有四個小部件:2個列表uicontrol
,1個按鈕uicontrol
以及1個靜態文本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
您能幫我設置文本字符串嗎?
這樣的事情應該做:
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.