How to share variables between button functions in App Designer?

20 ビュー (過去 30 日間)
Jackson Greaves
Jackson Greaves 2022 年 8 月 25 日
回答済み: millercommamatt 2022 年 8 月 26 日
In the attached code (I wrote a simplified version below to highlight what I'm trying to do) made in App Designer I have two buttons that each have callbacks. I'd like to be able to share my two variables 'app.roll' and 'app.tilt' between my two functions. No matter what combination of app or comp I use to prefix the variables the second function doesn't get the variable after the first is run. How do I correctly share variables?
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: ImportGPSDataButton
function AddButtonPushedFcn(comp, event)
app.roll = 2
app.tilt = 3
end
% Button pushed function: ExportTiltAnglesButton
function ExportTiltData(comp, event)
comp.ImportGPSDataButton.app.tilt
end
end

採用された回答

millercommamatt
millercommamatt 2022 年 8 月 26 日
You want to store these variable as a Property.
https://www.mathworks.com/help/matlab/creating_guis/share-data-across-callbacks-in-app-designer.html

その他の回答 (0 件)

カテゴリ

Find more on Migrate GUIDE Apps in Help Center and File Exchange

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by