MATLAB Answers

How to transfer data between apps using app designer

146 views (last 30 days)
Ho Nhu Y Nguyen
Ho Nhu Y Nguyen on 16 Jun 2016
Answered: TADA on 16 Jun 2019
Hello,
I am working on APP1 which has a parameter x, I open APP2 by a button in APP1 and change x (which I already transfer to APP2 from APP1) in APP2.
How can I update x in APP1 when I close APP2 and come back to APP1?
I tried to put in APP2CloseRequest: APP1.x = app.x but seems it doesnt work
Thanks

  1 Comment

Issa
Issa on 16 Jun 2019
hello
how you passed x from app1 to app2?

Sign in to comment.

Answers (2)

sam0037
sam0037 on 23 Jun 2016
Hi,
You can use public properties as explained in the link below to share data between apps. And you can add a closeRequestFcn using the Callback button in the Editor tab of the APPDESIGNER window. Remember to add "delete(app)" in the closeRequestFcn or else the app wont close. I have attached a sample APP to illustrate the above. Run the SendData app which sends the data to RecvData app. Hope this helps.

  3 Comments

Ho Nhu Y Nguyen
Ho Nhu Y Nguyen on 28 Jun 2016
Thanks for your response.
But what I meant is there is a button on app A, it will open app B and send data to B (I already did this) then I will change the data in app B and app A will be updated when closing app B and coming back to app A (not opening a new A).
Wouter
Wouter on 5 Apr 2017
Ho Nhu Y Nguyen did you already achieved this? I stubmle upon your topic now namely and am also wondering how to implement this behavior. Can you maybe share your findings if you have any?
Ho Nhu Y Nguyen
Ho Nhu Y Nguyen on 25 Apr 2017
Hi Wouter, sorry I couldn't find the solution and currently not working on this.

Sign in to comment.


TADA
TADA on 16 Jun 2019
The simplest solution would be to couple the two apps. When you open app B send the object of app A to it. Then when app B updates x, it can update the property of app A.
A more robust solution would be to uncouple the two apps and add a mediator class. The mediator knows both app A and app B. It passes all the data between the two back and forth. Both apps don't need to know each other, only the mediator.
The reason I say this implementation is more robust is because tomorrow you may need app A to communicate with a third class instead of app B for some specific functionality. In that case you don't need to change app A, only the mediator class.

  0 Comments

Sign in to comment.