Workaround for unsupported MATLAB Coder operators subsref/subsasgn
5 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!