Borrar filtros
Borrar filtros

Set the Variable 'Global' in GUI?

3 visualizaciones (últimos 30 días)
Alvi Syahrin
Alvi Syahrin el 11 de Mayo de 2013
Comentada: Amirhosein Ghenaati el 20 de Nov. de 2014
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.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 11 de Mayo de 2013
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 comentarios
Alvi Syahrin
Alvi Syahrin el 12 de Mayo de 2013
Thank you.
Amirhosein Ghenaati
Amirhosein Ghenaati el 20 de Nov. de 2014
yes i will do your method

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 12 de Mayo de 2013
Just say
global yourVariable;
in any function that needs to access the variable.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by