appdesigner output as of R2020a
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
as of R2020a, is matlab appdesigner able to have an output?
i am trying to have the output be imported to a text file
the output will be coordinates in an array
0 Commenti
Risposta accettata
Priysha LNU
il 24 Nov 2020
Hi,
There are three approaches that you can utilize for using data from an app created using App Designer in a different function or script. All these methods are based on saving the data from the app to the MATLAB Workspace, which the other function or script can access.
1. Using "assignin" to assign the value of the desired variable in the workspace. You can refer to the following documentation link for an example:
2. Using "export2wsdlg" to export variables to workspace :
3. Finally, you can also save the desired variables in a MAT file using the "save" command and then load the variables in the other function or script using the "load" command:
You can use any of the above approaches inside of the "CloseRequestFcn" such that when the app is closed the variables will be saved as the "CloseRequestFcn" is executed. Here is an example of using the "CloseRequestFcn" for a figure :
https://www.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html#buiwuyk-1-CloseRequestFcn
Having saved the variables in the workspace, you may export in the text file using the 'save()' function:
save('myFile.txt', '<variable name>', '-ASCII','-append');
Hope this helps!
DISCLAIMER: These are my own views and in no way depict those of MathWorks.
0 Commenti
Più risposte (1)
Michael
il 21 Apr 2023
A bit late of a response, but here's an approach to have output arguments for an appdesigner app without using assignin, for anyone that's searching for this:
1) In your appdesigner app, add a property for each variable you want to return
2) Also in the app, add a property called 'readyToExit'
3) Add a button to your GUI, with a button pushed callback that does this:
app.readyToExit = true;
4) Write a .m file to call the app like:
app = appName(inputArg);
%Here, the user interacts with the app like normal. waitfor blocks execution until the 'readyToExit' property is set to true by the button press
waitfor(app,'readyToExit',true);
%retrieve output from the GUI, now that the button has been pressed
outputArg1 = app.outputArg1;
outputArg2 = app.outputArg2;
%close the app
delete(app);
5) Instead of calling your app directly, call the .m file:
[outputArg1, outputArg2] = runApp(inputArg);
This will give you an appdesigner app that acts like a modal GUI.
0 Commenti
Vedere anche
Categorie
Scopri di più su Downloads in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!