How do I pass variables from one function to another in MATLAB GUIDE GUI's?

I have a GUI with two buttons.
I define a variable, A, in the first button when loading a file. I need access to that variables value in the callback for the second button.
Is there a way to pass this without using a global variable or putting it in the handles structure with GUIDATA function?

 Respuesta aceptada

Doug Hull
Doug Hull el 13 de Jun. de 2011

2 comentarios

i want to ask
why you put 0 in the handle ?
setappdata(0 , 'hMainGui' , gcf);
and what's the different with this ?
setappdata(gcf, 'thresh' , 121);
i have read the explanation from help.. but i still confuse
about this code
hMainGui = getappdata(0, 'hMainGui');
%you want to get the data from hMainGui ?
setappdata(hMainGui, 'fileName', fileName);
%you want to set a data, from fileName to fileName ?

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 13 de Jun. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by