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!

 채택된 답변

Guillaume
Guillaume 2017년 5월 17일

0 개 추천

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

댓글 수: 4

Ahmed Hossam
Ahmed Hossam 2017년 5월 17일
I've just seen this example after posting the question :D
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?
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 2018년 3월 2일
Yes, that was it for me too! Thanks so much!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Create Custom UI Components에 대해 자세히 알아보기

질문:

2017년 5월 17일

댓글:

2018년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by