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

3 views (last 30 days)
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

Doug Hull
Doug Hull on 13 Jun 2011
  2 Comments
danny agus
danny agus on 14 Jun 2011
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
danny agus
danny agus on 14 Jun 2011
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.

More Answers (1)

Image Analyst
Image Analyst on 14 Jun 2011

Categories

Find more on Environment and Settings 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!