Passing data into and out of an App

조회 수: 16 (최근 30일)
Chris
Chris 2019년 8월 12일
답변: Subhadeep Koley 2019년 8월 20일
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