How to assign the value of an ui.control element to a variable in public property in App Designer
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Fabian Lürßen
el 24 de Mayo de 2021
Editada: Mario Malic
el 24 de Mayo de 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 comentarios
Respuesta aceptada
Mario Malic
el 24 de Mayo de 2021
Editada: Mario Malic
el 24 de Mayo de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!