Using variables in multiple Callbacks
3 ビュー (過去 30 日間)
古いコメントを表示
I have two different pop up menu callbacks (popupmenu1 and popupmenu2). In both callbacks I produce a variable, urlA and urlB respectively. How can I use these variables in my pushbutton1 call back? Created GUI using GUIDE. I've read the documentation and help on handles, but I can't quite get anything working.
I tried using global variables, but it isn't working quite as it should.
1 件のコメント
回答 (1 件)
Parham Ebrahimi
2019 年 7 月 15 日
You can first store the variable in a structure inside one of the Callback functions. Look at the example below:
function first_callback(hObject,handles)
handles.myvariable=urlA
guidata(hObject,handles)
end
Then you can retrive the stored structure in the other callback function:
function second_callback(hObject,eventdata)
guidata(hObject)%This will give back the variable "urlA" from previous callback function
end
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!