The 'matlab.mixin.Copyable' class does not support code generation.
18 views (last 30 days)
Recently，I`m working on transforming a matlab project code into c/c++ code. But now I have a problem like the title said "The 'matlab.mixin.Copyable' class does not support code generation.". this problem is becuase I writed a class inheritance the matlab.mixin.Copyable class. Who can help me to solve this problem? thank you!
Michael on 5 Mar 2021
I got around this by creating a 'copy' method for my class. Here is a simple example.
classdef myobj < handle % used to be matlab.mixin.Copyable so I could copy
function obj = myobj(prop1, prop2)
obj.prop1 = prop1;
obj.prop2 = prop2;
function obj_out = copy(obj)
%COPY creates an exact copy of the object as a separate object
obj_out = myobj(obj.prop1,obj.prop2) %Create new instance of this object
%Copy the other properties of the class that aren't generated on construction
obj_out.prop3 = obj.prop3;
obj_out.prop4 = obj.prop4;