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

조회 수: 6 (최근 30일)
Tony Davis
Tony Davis 2015년 8월 27일
답변: Walter Roberson 2015년 8월 28일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2015년 8월 28일
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.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by