Sharing values between 2 app designer apps
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello guys, I'm trying to create 2 mlapp to pass data from one to another.
Basically I need to read value of a drop down menu which is present in App2 and then send this value (for example pressing a button) to an uitable in App1.
I have read many guides about this argument, even official one, but I don't understand how to write my code.
I hope someone could help me. Thanks
0 commentaires
Réponses (1)
Jon
le 13 Nov 2023
Modifié(e) : Jon
le 13 Nov 2023
I have attached two MATLAB Apps that provide a highly simplified example of how to do what I think you are asking.
Please save these two files to your working directory.
To run the example type main on the command line.
This will open main.mlapp, and the startup function in main.mlapp will open helper.mlapp. (The second app may be right behind the other one so move the windows around to see both)
On the helper app, pick an animal name from the drop down, and then press the button to send the data to the main app.
Look at the startup function for main, you will see it calls helper, and passes a reference to itself to helper so that helper can send data back. A property, called mainApp is defined in help.mlapp to store this reference. When help.mlapp opens, it's start up function saves this reference to the property app.mainApp so that it can access it when it needs it.
The callback for the send push button then get the data from the dropdown assigning it to the local variable, selection, and then sends the data to the main app using app.mainApp.animalTable.Data = {selection}
2 commentaires
Jon
le 13 Nov 2023
By the way, app designer also supports having multiple tabs within the same app. Could you design your application to just use separate tabs instead of having multiple apps. If so that would be a lot simpler, and everything would be self contained in one app.
Jon
le 15 Nov 2023
Did this answer your question? Did you have any further questions. If this answered your question please accept the answer so that others with similar issues will know an answer is available
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!