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

8 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

MathWorks Support Team
MathWorks Support Team am 28 Dez. 2021
Bearbeitet: MathWorks Support Team am 28 Dez. 2021
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.

Weitere Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by