The 'matlab.mixin.Copyable' class does not support code generation.

11 ビュー (過去 30 日間)
bendong hou
bendong hou 2019 年 5 月 24 日
コメント済み: zeng zeng 2025 年 1 月 13 日
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!
  2 件のコメント
Michael
Michael 2021 年 3 月 2 日
I have the same problem. Were you able to resolve this?
zeng zeng
zeng zeng 2025 年 1 月 13 日
I also have the same problem.

サインインしてコメントする。

回答 (1 件)

Michael
Michael 2021 年 3 月 5 日
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
properties
prop1
prop2
prop3
prop4
end
methods
function obj = myobj(prop1, prop2)
if nargin>0
obj.prop1 = prop1;
obj.prop2 = prop2;
end
end
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;
end
end
end

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by