Borrar filtros
Borrar filtros

Workaround for unsupported MATLAB Coder operators subsref/subsasgn

4 visualizaciones (últimos 30 días)
Hello!
I have an object obj which overloads the operator subsasgn, where the call is for example
obj(1:3) = NaN;
This is not supported by the MATLAB Coder. I therefore wanted to ask, if there is a workaround to solve this. I thought about telling the Coder to convert the subsasgn operator call to a plain function call like
obj.subsasgn( 1:3, NaN );
without the interpretation of an operator and then make the implementation in subsasgn dependent on the target with coder.target('MATLAB'). Is this possible and how?
Thank you for the support!

Respuesta aceptada

Kyle
Kyle el 12 de Dic. de 2023
Hi Ulrich,
Unfortunately, as you noted, MATLAB Coder does not support subsref or subsasgn.
MATLAB Coder has a limited set of support for objects. In your case, I am not sure there is a viable workaround. The expression you used as an example is assigning NaN into a subset of elements of an object array. However, even arrays of objects are not supported in MATLAB code generation.
Rather than try to get around the object array limitation, you might have more luck with using an array of structures instead.

Más respuestas (0)

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by