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?

 Risposta accettata

2 Commenti

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 ?

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by