Passing objects from app designer to the workspace

20 views (last 30 days)
Hello , I'm using app designer and I am creating object when some button clicked, (in the callback function) i'm trying to use the object that created in the callback funcion in the workspace. I know that i can create some "global" object in the properties and then use app.obj. There is other way that i can pass the object from the callbackfunction to the workspace? or the only way is to use the properties.
Thank you very much :)

Accepted Answer

Allen
Allen on 19 Oct 2022
Though I would recommend using one of @Adam Danz's solutions since they are typically a safer method of passing data, assignin can be used to programmatically assign a variable to the workspace.
See the following help page for details on how to use the assignin function.
  5 Comments
Ron
Ron on 26 Oct 2022
I am using appDesigner,
Function RunButtonPushed(app,event) //NOTE : this is on gray cant add a return value
obj=importdata(somepath) //NOTE : The path is matlab data that have run method
obj.run() // NOTE : after the run , nothing happens because the variable
end obj is uknown in the workspace i guess beacuse in the
end of this function there is END

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 18 Oct 2022
The best way to access the object created by an app is to store the handle to the object as a public property of the app and to access that handle through the app object, stored as a variable in your workspace.
More info

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by