Inheriting from 'matlab.mi​xin.Hetero​geneous' in Coder

9 views (last 30 days)
In MATLAB, inheriting from matlab.mixin.Heterogeneous for the base class will allow nice polymorphism. However, it appears this isn't supported in Coder. First, can anyone confirm that Coder cannot use matlab.mixin.Heterogeneous, and if not, does anyone have a nice workaround.
For instance, I have the usual setup of an ABC called Shape, which is derived from both handle and matlab.mixin.Heterogeneous. Then I have Rectangle and Circle derived from Shape. I'd like to be able to have an array like:
classdef Shape < handle & matlab.mixin.Heterogeneous
classdef Circle < Shape
classdef Rectangle < Shape
harray = [Rectangle(height, width), Circle(radius)];
In Matlab, harray becomes a type "1x2 heterogeneous Shape (Rectangle, Circle) array"
In Coder, I get the error "Base class 'matlab.mixin.Heterogeneous' cannot be loaded." during the build.
Any ideas how this could be approached? Before I do something crazy, I just want to check if there's something obvious I'm missing.

Answers (1)

Walter Roberson
Walter Roberson on 28 Aug 2015
Limitations in class support is supposedly documented at http://www.mathworks.com/help/coder/ug/how-working-with-matlab-classes-is-different-for-code-generation.html . Unfortunately I do not have permission to access the document myself.

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!