Accessing variables between pushbuttons in MATLAB GUI

Hi,
I have two pushbuttons in MATLAB GUI. When I press one pushbutton it executes certain set of codes including function call. The variables returned by this function call need to be sent to the function call which executes when other push button is pressed. But, I get the following error:
Error using hg.uicontrol/get The name 'MySet' is not an accessible property for an instance of class 'uicontrol'.
Error in test3>pushbutton_forfind_Callback (line 481) MySet = get(handles.pushbutton1,'MySet');
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in test3 (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)test3('pushbutton_forfind_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
MySet is the variable returned by function called by first pushbutton which needs to be passed to another function call in second pushbutton. How can I resolve this error?
Thanks.

 採用された回答

Sean de Wolski
Sean de Wolski 2012 年 7 月 30 日

0 投票

How are you setting 'MySet' to be a field of handles? You need to use either setappdata & getappdata or guidata.

3 件のコメント

Rinachi Garg
Rinachi Garg 2012 年 7 月 30 日
編集済み: Walter Roberson 2012 年 7 月 30 日
I m doing this in function call of pushbutton 1:
handles.MySet = MySet;
guidata(hObject, handles);
Then retrieving in another pushbutton2 by:
MySet = get(handles.pushbutton1,'MySet');
Walter Roberson
Walter Roberson 2012 年 7 月 30 日
Just
MySet = handles.MySet;
Rinachi Garg
Rinachi Garg 2012 年 7 月 30 日
Thanks a lot for pointing out this. I am so happy that it worked.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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