Best Ways to Save Objects with Coder Support

3 ビュー (過去 30 日間)
Michael
Michael 2022 年 8 月 22 日
コメント済み: Michael 2022 年 8 月 30 日
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.

採用された回答

Nathan S
Nathan S 2022 年 8 月 30 日
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 件のコメント
Michael
Michael 2022 年 8 月 30 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by