The answer is that it does not support object arrays. Here is the workaround
Object Arrays in Code Generation
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michael
el 15 de Jun. de 2022
Comentada: cui,xingxing
el 26 de Oct. de 2022
Does code generation support arrays of custom objects? Here is a simple class.
classdef MyClass
properties
value
end
methods
function obj = MyClass(valueIn)
if nargin>0
obj.value = valueIn;
else
obj.value = NaN;
end
end
end
end
I'd like to preallocate an array of these objects in my code. I have tried all of the following. They work in Matlab but fail in code generation.
myClassArray(1:dim1,1:dim2) = MyClass;
myClassArray(dim1,dim2) = MyClass;
myClassArray = pulse;
myClassArray(dim1,dim2) = MyClass;
Any ideas if arrays of custom class objects are supported? If so, how best to preallocate an empty array of the objects?
Thanks.
0 comentarios
Respuesta aceptada
Michael
el 15 de Jun. de 2022
1 comentario
cui,xingxing
el 26 de Oct. de 2022
Hi, Can you solve this question?
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Coder en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!