Passing data into and out of an App
조회 수: 19 (최근 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?
댓글 수: 0
답변 (1개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!