How to assign the value of an ui.control element to a variable in public property in App Designer
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Fabian Lürßen
le 24 Mai 2021
Modifié(e) : Mario Malic
le 24 Mai 2021
Hi,
in my callbacks I can simply say:
% Button pushed function: StartButton
function StartButtonPushed(app, event)
A = app.Spinner1.Value;
But now I need to define A in public or private property to get access from all callbacks. But when I write:
properties (Access = public)
Property % Description
A = app.Spinner1.Value;
I get this Error:
Invalid default value for property 'A' in class 'Example':
Unable to resolve the name app.Spinner1.Value.
0 commentaires
Réponse acceptée
Mario Malic
le 24 Mai 2021
Modifié(e) : Mario Malic
le 24 Mai 2021
Hey,
The public access to the property or the method means that if you start your app from the outside, from the Command Window like this, you will be able to get property named "Property" as defined in that block.
app = NameOfApp;
app.Property % ask what's inside Property
So, what you need is to reference the property of the app correctly.
properties (Access = public)
Property % Description
A
end
Notice, that your app has now property A, and you index into it like this
app.A
So, you can assign a value to property like this
% Button pushed function: StartButton
function StartButtonPushed(app, event)
app.A = app.Spinner1.Value;
end
That should be it, before asking for similar questions, take a look at tutorials here and introductory apps in the App Designer, and there are plenty of questions in MATLAB Answers.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!