Filter löschen
Filter löschen

Workaround for unsupported MATLAB Coder operators subsref/subsasgn

4 Ansichten (letzte 30 Tage)
Ulrich
Ulrich am 11 Dez. 2023
Beantwortet: Kyle am 12 Dez. 2023
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!

Akzeptierte Antwort

Kyle
Kyle am 12 Dez. 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.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by