How can I access variables within an App Designer app after I close the app?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 28 Déc 2021
Modifié(e) : MathWorks Support Team
le 28 Déc 2021
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?
Réponse acceptée
MathWorks Support Team
le 28 Déc 2021
Modifié(e) : MathWorks Support Team
le 28 Déc 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.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!