Constant properties in classes

Hi,
is it possible to define a constant property in a class which depends on other constant properties in the same class?
Would that also be correct?
thank you for your answer in advance!

 Respuesta aceptada

Guillaume
Guillaume el 17 de Mayo de 2017

0 votos

Yes, constant properties can be calculated from other constant properties. It's the first example in the doc actually.

4 comentarios

Ahmed Hossam
Ahmed Hossam el 17 de Mayo de 2017
I've just seen this example after posting the question :D
New
New el 29 de Jul. de 2017
Properties (Constant)
a = 1;
b = a+1;
end
function ButtonPushed(app, event)
app.EditField.Value = app.EditField.Value + app.b;
end
Message: Invalid default value for property 'b' in class 'App1': Undefined function or variable 'a'.
What's wrong?
Guillaume
Guillaume el 29 de Jul. de 2017
As shown in the very first example in the link in my answer, you have to use the syntax:
classdef App1
properties (Constant)
a = 1;
b = App1.a+1;
end
Ganesh Gajavelli
Ganesh Gajavelli el 2 de Mzo. de 2018
Yes, that was it for me too! Thanks so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Function Handles en Centro de ayuda y File Exchange.

Preguntada:

el 17 de Mayo de 2017

Comentada:

el 2 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by