How can I access variables within an App Designer app after I close the app?
조회 수: 8 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2021년 12월 28일
편집: MathWorks Support Team
2021년 12월 28일
I would like to create a script that opens an app I created in App Designer, waits until this app is closed, then processes the data from the app. However, I can't seem to find a way to pass data from the app to the script/Base Workspace. Is it possible to do this? If so, how?
채택된 답변
MathWorks Support Team
2021년 12월 28일
편집: MathWorks Support Team
2021년 12월 28일
There may be many ways to accomplish this, depending on your specific workflow. Here is one way of achieving this:
1. Create a public property named 'Output' in the app. This will be a structure to hold all desired values:
properties (Access = public)
Output % This will store the app's output
end
2. In the callback function for each value you would like to keep track of set/update the corresponding value in the app's output struct:
function SpinnerValueChanged(app, event)
value = app.Spinner.Value;
app.Output.Value1 = value;
end
3. In the 'UIFigureCloseRequest' function (invoked when the app is closed), save the app's output structure. This can be done in two ways:
(a) Save directly to Base Workspace via 'assignin':
function UIFigureCloseRequest(app, event)
assignin('base', "app_output", app.Output);
delete(app)
end
(b) Save to a MAT file:
function UIFigureCloseRequest(app, event)
app_output = app.Output;
save("app_output.mat", "app_output");
delete(app)
end
Please refer to the documentation page on sharing data in App Designer apps for further information.
댓글 수: 0
추가 답변 (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!