How to pass value of a variable from one push button to another in matlab guide

2 ビュー (過去 30 日間)
How to pass value of a variable from one pushbutton to another pushbutton in matlab guide?

採用された回答

Geoff Hayes
Geoff Hayes 2015 年 10 月 28 日
Pavikirthi - in the callback for your first pushbutton, update the handles structure with the value of the variable that you wish to save. i.e.
handles.myVar = someValue;
Now save the updated handles structure using guidata as
guidata(hObject, handles);
(The above assumes that both hObject and handles are inputs to your callback.)
Now, in the other pushbutton callback, you can reference myVar directly using the input handles object as
if isfield(handles,'myVar')
% do something with this variable
end
The above check makes sure that myVar is a field in handles before you try to access it.
  2 件のコメント
pavikirthi
pavikirthi 2015 年 10 月 28 日
Yeah it works fine.Thanks.
Muhammad Talha Bashir
Muhammad Talha Bashir 2022 年 1 月 12 日
but how can i access more than one variable from other pusbutton?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by