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

8 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 28 de Dic. de 2021
Editada: MathWorks Support Team el 28 de Dic. de 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.

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by