How can I access variables within an App Designer app after I close the app?

8 ビュー (過去 30 日間)
I would like to create a script that opens an app I created in App Designer, waits until this app is closed, then processes the data from the app. However, I can't seem to find a way to pass data from the app to the script/Base Workspace. Is it possible to do this? If so, how?

採用された回答

MathWorks Support Team
MathWorks Support Team 2021 年 12 月 28 日
編集済み: MathWorks Support Team 2021 年 12 月 28 日
There may be many ways to accomplish this, depending on your specific workflow. Here is one way of achieving this:
1. Create a public property named 'Output' in the app. This will be a structure to hold all desired values:
properties (Access = public)
Output % This will store the app's output
end
2. In the callback function for each value you would like to keep track of set/update the corresponding value in the app's output struct:
function SpinnerValueChanged(app, event)
value = app.Spinner.Value;
app.Output.Value1 = value;
end
3. In the 'UIFigureCloseRequest' function (invoked when the app is closed), save the app's output structure. This can be done in two ways:
(a) Save directly to Base Workspace via 'assignin':
function UIFigureCloseRequest(app, event)
assignin('base', "app_output", app.Output);
delete(app)
end
(b) Save to a MAT file:
function UIFigureCloseRequest(app, event)
app_output = app.Output;
save("app_output.mat", "app_output");
delete(app)
end
Please refer to the documentation page on sharing data in App Designer apps for further information.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by