In Matlab, I have the two classes
classdef A < matlab.mixin.Heterogeneous
properties
a;
end
methods
function obj = A(varargin)
obj.a = 3;
end
end
end
and
classdef B < A
properties
b;
end
methods
function obj = B(varargin)
obj = obj@A(varargin);
obj.b = 4;
end
end
end
I now try to initialize an array of length 2 of type B
:
>> objarray(2) = B
objarray =
1x2 heterogeneous A (A, B)
Properties:
a
Methods, Superclasses
Why does Matlab insist on making it of class A ? And how can I insist that it be of class B
instead?
EDIT:
Using the debugger it is apparent that Matlab never enters the constructor for B
when creating objarray(1)