Matlab C Coder gives error for cloning object

2 次查看(过去 30 天)
Hi, i am trying to clone my trackergnn object but the coder gives me this error
Undefined function or variable 'loadObjectImpl'.
It works well on matlab code but when i am trying to convert it to C code with coder it gives this error.
Coder does not give an error for functions like saveObjectImpl but loadObjectImpl. Why is that ?

回答(1 个)

Matan Silver
Matan Silver 2022-4-26
Hi Anil,
It looks like loadObjectImpl is not in the list of officially supported functions for System Objects (trackerGNN is a System Object):
If you are ok with the System Object being loaded at codegen-time and not run-time of the generated code, you may be able to use "coder.load" to load the information from the MAT file:
However, without more information about your use-case and what the code looks like, it's hard to say if this solution would work for you. Would you be able to upload some simple reproduction files and a script to call codegen on those files and trigger the error? This could help figure out if there's a different viable workaround.
Matan
  3 个评论
Matan Silver
Matan Silver 2022-4-29
Hi Anil,
After some more investigation and discussion with my colleagues, I have some more information for you:
  • It looks like the "clone" method on system objects is not supported for code generation. Note in the MATLAB Documentation page for "clone", there is no "Extended Capabilities" section for C/C++ code generation support: https://www.mathworks.com/help/matlab/ref/clone.html . Usually the absense of such a section in the doc indicates code generation is not supported.
  • You can actually also see that in this implementation for cloneImpl, the "loadObjectImpl" method is being called. This method is not on the list of system object supported methods for code generation, and this is probably why you are receiving this particular error message: https://www.mathworks.com/help/coder/ug/use-system-objects-in-matlab-code-generation.html
  • If you need more than one trackerGNN object at runtime in your generated code, I think the idiomatic way to do this would be to instantiate more than one object to begin with, instead of cloning an existing object. Unfortunately limitations in system objects and code generation prevent supporting "clone" for code generation, for now.
Could you describe a bit more why you need to use the "clone" method? Perhaps there might be another workaround (besides instantiating more than one trackerGNN) which could be applied, depending on the reasons you need to copy a trackerGNN with all of its state at runtime in generated code.
Hopefully this helps a bit, and feel free to reply if you have more questions or info. Thanks,
Matan
Anil Yilmaz
Anil Yilmaz 2022-5-9
Hi matan, thanks for replying.
I wanted to change nontunable parameters of the trackergnn object but not the other properties, especially tracks. So i initilized new trackergnn object with new parameters, then tried to copy tracks and some neccessary properties. Unfortunately i could not do this. After that i changed tunable properties and managed to manipulate some. Thanks for help.

请先登录,再进行评论。

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by