Workaround for unsupported MATLAB Coder operators subsref/subsasgn

조회 수: 5 (최근 30일)
Ulrich
Ulrich 2023년 12월 11일
답변: Kyle 2023년 12월 12일
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!

채택된 답변

Kyle
Kyle 2023년 12월 12일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by