matlab - Initializing an array of subclass objects creates a heterogeneous superclass array -


in matlab, have 2 classes

classdef < matlab.mixin.heterogeneous     properties         a;     end     methods         function obj = a(varargin)            obj.a = 3;         end     end end 

and

classdef b <     properties         b;     end     methods         function obj = b(varargin)             obj = obj@a(varargin);             obj.b = 4;         end     end end 

i try initialize array of length 2 of type b:

>> objarray(2) = b  objarray =     1x2 heterogeneous (a, b)    properties:        methods, superclasses 

why matlab insist on making of class ? , how can insist of class b instead?

edit: using debugger apparent matlab never enters constructor b when creating objarray(1)

i've never tried myself, believe matlab.mixin.heterogeneous has method getdefaultscalarelement can implement/override yourself, define how backfill initial elements of array when assign later element. see halfway down this documentation page more information.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -