MATLAB: Do I get the error “Invalid default value for property” when trying to define one default instance variable value in terms of another

MATLAB

Why do I get the error "Invalid default value for property" when trying to define one default instance variable value in terms of another?
e.g.
classdef Example
properties
A = {'a','b','c'}
B = [A,'d']
end
end
gives me the following error when I try to instantiate an example object
>> Example
Invalid default value for property 'B' in class 'Example':
Undefined function or variable 'A'.

Best Answer

It is easier to see the reason for this issue once you fully-qualify the name of an instance variable with which you are defining another.
e.g.
classdef Example
properties
A = {'a','b','c'}
B = [Example.A,'d']
end
end
yields the error
>> Example
Invalid default value for property 'B' in class 'Example':
The property 'A' in class 'Example' must be accessed from a class instance because it is not a Constant property.
Because 'B' is defined in terms of A, we must either define 'A' to be a "Constant" property or we must initialize B in the constructor.
i.e.
classdef Example
properties (Constant)
A = {'a','b','c'}
end
properties
B = [Example.A,'d']
end
end
or
classdef Example
properties
A = {'a','b','c'}
B
end
methods
function obj = Example()
obj.B = [obj.A,'d'];
end
end
end