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?

 Accepted Answer

2 Comments

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 ?

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!