accessing variables in multiple .mlapp files - Matlab app designer

hello,
i am wondering how to share variables between 2 matlab app designer (.mlapp) files. I have one file GUI2.mlapp and another file GUI4.mlapp. I would like to share a variable from GUI.mlapp to GUI4.mlapp. How am i able to do this?
matlab version: R2019B
Thank you!

 採用された回答

Adam Danz
Adam Danz 2021 年 6 月 11 日

0 投票

Although that page comprehensively explains the process, here's an answer that shows a step-by-step process of declaring app properties. You can use "public" properties.

7 件のコメント

Joseph Kutteh
Joseph Kutteh 2021 年 6 月 14 日
thank you!
Joseph Kutteh
Joseph Kutteh 2021 年 6 月 15 日
%my first app called GUI2.mlapp
properties(Access = public)
name = ' ';
%my second app called GUI4.mlapp
function startupFcn(app)
app2handle = GUI2
app2handle.name
end
in the code of my first app (GUI2) i edit the value of the variable "name", then i click a button which opens the GUI4 app. The value i see that is printed in the command window is ' '. Any idea as to why this happens even though i change the value of "name" before i run the GUI4 app?
Thank you
Joe
Adam Danz
Adam Danz 2021 年 6 月 15 日
It looks like you're opening GUI2 from within GUI2. I don't see any reference to GUI4.
Joseph Kutteh
Joseph Kutteh 2021 年 6 月 15 日
should i have this?
%my first app called GUI2.mlapp
properties(Access = public)
name = ' ';
%my second app called GUI4.mlapp
function startupFcn(app)
app2handle = GUI4 % changed this line
app2handle.name
end
Adam Danz
Adam Danz 2021 年 6 月 15 日
If you're calliing GUI4 within GUI2 and want to return the name property of GUI4, then yes.
Joseph Kutteh
Joseph Kutteh 2021 年 6 月 15 日
i want to access the updated value of "name" in GUI4. "name" gets changed in GUI2 via a text field.
Adam Danz
Adam Danz 2021 年 6 月 15 日
The line below with the leftward arrow is accessing the name propery of GUI2!
If this function is within GUI4, then use app.name since the app content pertains to GUI4.
%my second app called GUI4.mlapp
function startupFcn(app)
app2handle = GUI2
app2handle.name % <------------------------
end

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

質問済み:

2021 年 6 月 11 日

コメント済み:

2021 年 6 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by