Passing data between UIFigures

4 views (last 30 days)
Muslim Danesh
Muslim Danesh on 21 Nov 2017
Commented: Amir Abedin on 4 Jul 2020
Hi. I'm building a program by app designer that has 3 different window. My quesiton is, how I can share data and variables between them?
  1 Comment
Adam
Adam on 21 Nov 2017
Since AppDesigner is based on classes it is very easy to just set data from one in another, but you haven't given any details of how you create your windows so a generic answer is far too vague and time-consuming.

Sign in to comment.

Answers (2)

Adam
Adam on 22 Nov 2017
app2.R = R;
would work if you just want R, you don't need app1, but equally:
app2.field3 = app.field3;
for example would also work, though you should name properties as descriptively as possible.
Obviously whatever you choose you must define the property in app2.
  4 Comments
Adam
Adam on 22 Jan 2019
Within a given UI class in App Designer the object itself is usually referred to as app, but in a your own function you can call it whatever you want and when you create your two GUIs you will give them each your own name that is used external to the object.
e.g.
myApp1 = App1( );
myOtherApp = App2( );
myApp1.someProperty = someValue;
myOtherApp.someOtherProperty = someOtherValue;
Fei Gao
Fei Gao on 22 Jan 2019
Thank you! I got it.

Sign in to comment.


Muslim Danesh
Muslim Danesh on 21 Nov 2017
Let say that in first class (app1), I have a piece of code for Run button callback:
function RunButtonPushed(app, event)
V = app.field1.Value;
p = app.field2.Value;
R = V*p;
app.field3.Value = R;
%open the second window
app2;
end
Then in second class (app2), after pressing the Solve button, I'm going to the value of R (from the first window). Now what is the content to be used for retrieving it from app1 classdef.

Categories

Find more on Develop uifigure-Based Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!