Pass Panel components to function with App Designer
Show older comments
Hi folks,
I wonder if there's a way to pass the items of a panel in App Designer somehow like a struct.

Let's say I have a simple GUI with 3 spinners on a panel as shown above. Now I for example press a button which calls a function:
xy = myFunction(app.Panel);
What I want to do in the function is something like:
function xy = myFunction(Panel)
xy.a = Panel.Spinner.Value;
xy.b = Panel.Spinner2.Value;
xy.c = Panel.Spinner3.Value;
end
Is this possible?
Or do I have to pass every single value to my function?
I know I could do something like
xy = myFunction(app);
But I don't want to share the whole app data with my function. And in RL my panel not only contains 3 items.
Thanks in advance.
Accepted Answer
More Answers (1)
Avratanu Biswas
on 27 Nov 2020
Edited: Avratanu Biswas
on 27 Nov 2020
Hi ,
If I understood your question correctly, it is possible to pass all the components within an app ( as long as it is defined as a global property) . But you need to assign each values of the spinner separately in your case .
% for example
function xy = myFunction(app)
xy.a = app.Spinner.Value
xy.b = app.Spinner2.Value
xy.c = app.Spinner3.Value
end
1 Comment
Dominik Müller
on 30 Nov 2020
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!