How to use public properties in matlab app designer?

Hi
I have two apps , the one in invoking the other. app2 is invoking the app 3. The app 3 consists of a listbox which is supposed to show up as many times as the number of zones (chosen by the user in app 2)
I thought I was supposed to define antall_soner as public property in both app2 and in app 3 as both of them are using this variable but the value of it is set in app2.
I dont know why but I an getting a warning when I am in the code view though I have set app. antall_soner everywhere.
Can anybody help me with my problem?

 Accepted Answer

I have modified your apps and attached them here.
In app3, I added a Callingapp property. In code view, I clicked "App Input Argument" and added "app2" as an input variable. Within the startup function, I added, "app.Callingapp = app2".
For app2, I modified how you called app3. Instead of just app3, it is now app3(app) - this includes all the property variables in app2 as an input to app3.
Please also see the link here on creating multiwindow apps in App Designer:
Let me know if you have any more questions.

6 Comments

@Kevin Holly Hi! I am wondering whether it should be app3(app2 ) in app2 where I am calling app3 , you wrote app3(app).
No, it should be app. Within every app, you access the property variables using app. For instance, to access the uifigure, you would type app.UIFigure.
The reason app3 uses app2 is arbitrary. When I assigned the input argument for app3, I wrote app2. I could have written "mainapp", then I could have written "app.Callingapp = mainapp" within the startup function of app3.
@Kevin Holly Hi again! :) How am I supposed to 'read ' this syntax:
app.Callingapp.antall_soner
Is it like that antall_soner is a variable of an app that goes in the other app as a variable..? So it is somehow similiar to use of a table or when we want to access a variable from a table . And we have app in front of the name because we are talking about a public property.
I meant you sent the whole app as a public variable if I understood it correctly..?
@Kevin Holly By the way could you just have written app.app2 in the startup function and just app2 as the public property . If I understood it correctly you just chose to have new variable and set it equal to app2 so it could be easier to understand the code..?
In app2, app3 was called with the input "app" as such:
app3(app)
"app" here includes access to all of the property variables in app2.
In app3, I added a Callingapp property. In code view, I clicked "App Input Argument" and added "app2" as an input variable. Within the startup function
app.Callingapp = app2
You could have named the input variable "mainapp" and written the startup function as:
app.Callingapp = mainapp
Now if you want to access any of the property variables from app2 in app3, you can type:
app.Callingapp.VariableName
where "VariableName" is one of the property variables in app2.

Sign in to comment.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer 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!