I'm working with MATLAB GUI.
When I'm trying to access the variable which was defined with the push button, it is not defined in the pop up menu. The variables; it should be set 'global', so it is defined in the whole program. And I can use it in any callback.
Do you guys have any idea of how to make the variables 'global'?
Your help will be much appreciated.
Thank you.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 11일

2 개 추천

If you want to use it in any callback use guidata
handles.yourvar=yourvar
guidata(hObject,handles)
To use the variable yourvar
yourvar=handles.yourvar

댓글 수: 2

Alvi Syahrin
Alvi Syahrin 2013년 5월 12일
Thank you.
Amirhosein Ghenaati
Amirhosein Ghenaati 2014년 11월 20일
yes i will do your method

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

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 5월 12일

1 개 추천

Just say
global yourVariable;
in any function that needs to access the variable.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by