필터 지우기
필터 지우기

Best Ways to Save Objects with Coder Support

조회 수: 1 (최근 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 CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by