필터 지우기
필터 지우기

Pass Variable to Calling App

조회 수: 11 (최근 30일)
Chris Nemecek
Chris Nemecek 2020년 4월 27일
댓글: Chris Nemecek 2020년 4월 30일
I have searched around for the best practice to pass an app variable back to the calling app. For example, app1 is the main app and calls app2. I can easily pass variables into app2 via h = app2(a, b) when I run it from app1. However, I would like to pass back a and b to the calling app when app2 is closed. I have been using setappdata and getappdata, but don't believe this is technically the right approach.
app1 pseudocode:
function ButtonPress(app)
a = 5;
b = 10;
h = app2(a,b); % app2 modifies a and b
uiwait(h.UIFigure)
% at this point when app2 is closed, i want a and b returned to app1
end

채택된 답변

Mohammad Sami
Mohammad Sami 2020년 4월 28일
Please refer to the following documentation on how to pass data between appdesigner apps.
https://www.mathworks.com/help/matlab/creating_guis/creating-multiwindow-apps-in-app-designer.html
  댓글 수: 3
Mohammad Sami
Mohammad Sami 2020년 4월 30일
The second approach will work as well.
In my opinion using a function to update the properties may be preferable in certain cases.
Example if you want the change to be reflected in the UI in any way. The function can execute additional code to update the UI in addition to setting the properties.
A function can also do validation checks e.t.c.
Chris Nemecek
Chris Nemecek 2020년 4월 30일
Those are good points. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by