Matlab C Coder gives error for cloning object

1 view (last 30 days)
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 ?

Answers (1)

Matan Silver
Matan Silver on 26 Apr 2022
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 Silver
Matan Silver on 29 Apr 2022
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: . 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:
  • 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,
Anil Yilmaz
Anil Yilmaz on 9 May 2022
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.

Sign in to comment.


Find more on Characters and Strings in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!