I am shocked to discover that MATLAB seems to violate polymorphism when it comes to equivalence of handles in handle classes.
I presume that the handle to a handle class object is synonymous to a pointer of a specific class.
E.g.
Let
classdef MyBase < handle ... end
classdef MyDerived < MyBase ... end
1. array = repmat(MyBase,1,n);
2. array(1) = MyBase; % No error
3. array(2) = MyDerived; % Error!
The assignment in line 3 should not error, as the array is of the parent of MyDerived, in accordance with the above rule of equivalence of pointers under polymorphism.
Of course, one explanation is that handles are not synonymous to pointers. And the workaround is to deploy the cell array. Not nice.
What is the official explanation to the above anomaly?