Passing data into and out of an App

16 次查看(过去 30 天)
I am new to Apps and would like to make sure I am clear on how to it is best to get data into and out of an App.
I need to be able to run my App from an mfile and pass it input and get outputs from it. Running my App from the "App" tab is secondary, where IO can be done explicitly with user input this is not a problem.
You can run a packaged App from code via
matlab.apputil.run('PlotDataAPP')
But this does not seem to let you pass data directly in or get data directly out.
Else it looks like you can run the .mlapp directly from code with input arguemts via startupFcn(). But I dont see a good way to extract data from the App back into the mfiles workspace other than use of a global variable or the 'base' workspace.
% From within my mfile code
global myOutputData
foo = myApp(myInputData); % myOutputData is also a global within a function in myApp
uiwait(foo.UIFigure); % pause mfile execution to let the user do things in myApp
plot(myOutputData) % do something with mOutputData that was set within myApp
The above code works but seems very sloppy.
Could I use global varialbes to get data into and out of a packaged App where my mfile can then use matlab.apputil.run?
Is there a better way to do data IO? Reading/writing mat files is not an option - cant risk propriatary data being saved in odd places. Passing data through the 'base' workspace could be done but seems about a slopy as using globals.
Is there any real difference between running the packaged app and running the .mlapp?

回答(1 个)

Subhadeep Koley
Subhadeep Koley 2019-8-20
Since you prefer not to use global declaration or importing variable from Base Workspace, you can use properties option of the App Designer. properties is the best way to share data within an app because properties are accessible to all functions and callbacks in an app.
Refer the documentation here.

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by