Matlab C Coder gives error for cloning object

조회 수: 2 (최근 30일)
Anil Yilmaz
Anil Yilmaz 2022년 4월 26일
댓글: Anil Yilmaz 2022년 5월 9일
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