フィルターのクリア

Workaround for unsupported MATLAB Coder operators subsref/subsasgn

4 ビュー (過去 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 Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by