Best Ways to Save Objects with Coder Support

2 Ansichten (letzte 30 Tage)
Michael
Michael am 22 Aug. 2022
Kommentiert: Michael am 30 Aug. 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.
Thanks.

Akzeptierte Antwort

Nathan S
Nathan S am 30 Aug. 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 Kommentar
Michael
Michael am 30 Aug. 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.
Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by