Effacer les filtres
Effacer les filtres

Best Ways to Save Objects with Coder Support

5 vues (au cours des 30 derniers jours)
Michael le 22 Août 2022
Commenté : Michael le 30 Août 2022
I have a couple of custom classes I've made for my project and I am using Coder to run my code as an executable. I am processing segments of data and generating instances of my objects every few seconds. I want to save my objects during the run or after it has completed for archiving/debugging reasons. I don't see any Coder supported functions for this other than the low level fwrite or fprintf. My only idea so far is to write a script that reads all of the properties of my class, converts them to strings with sprintf, and then writes them to a file. This isn't a clean option and I'd like to know if there is a better way to write objects to disk that is supported for code generation.
FYI: my classes have properties that are mixed data types - some of doubles, some are strings, some are other objects.
I'm afraid the answer is 'Just write your own program that writes you objects to a file.' but I don't want to launch down that path until I've checked in with someone else who might know better than I.

Réponse acceptée

Nathan S
Nathan S le 30 Août 2022
Unfortunately, Coder doesn't have any good tools for this (aside from fwrite/fprintf). This is a common problem, and we know that Coder's workflows don't make it easy right now. Hopefully we can provide some better tools in a future release, although that doesn't help you much right now.
  1 commentaire
Michael le 30 Août 2022
Thanks for the response Nathan. It is good to know that I won't be wasting time building something for myself now that I know there isn't a pre-built option out there. Honestly, the writing isn't the biggest problem. The harder part is reading these variables back in in the future. A coder compatible save and load would be really helpful.

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur MATLAB Coder dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by