Using variables in multiple Callbacks

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

Adam
Adam 2015년 12월 4일
편집: Adam 2015년 12월 4일
Since you have read the documentation on handles it would help if you post what you currently have.
In particular this you should read up on these for sharing data between callbacks:

댓글을 달려면 로그인하십시오.

답변 (1개)

Parham Ebrahimi
Parham Ebrahimi 2019년 7월 15일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2015년 12월 4일

답변:

2019년 7월 15일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by