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?

 採用された回答

Doug Hull
Doug Hull 2011 年 6 月 13 日

0 投票

2 件のコメント

danny agus
danny agus 2011 年 6 月 14 日
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 2011 年 6 月 14 日
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 ?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by