필터 지우기
필터 지우기

How do I save MATLAB data for a C/C++ based embedded system?

조회 수: 2 (최근 30일)
Yang Renda
Yang Renda 2024년 2월 6일
댓글: Yang Renda 2024년 2월 7일
Say that I have used MATLAB coder to create multiple C codes that I shall apply on an STM32.
The C codes take a lot of parameters as input, and I do not want to write data as header files, nor do I want to write a program to do that, not if there are existing solutions, or better alternatives.
The application does not call for the need of a single board computer, and STM32 cannot store nor read .mat files (I think).
What are my options?

채택된 답변

Sumit Ghosh
Sumit Ghosh 2024년 2월 7일
You can achieve this using coder.read and coder.write.
In short, coder.write(fileName,data) stores the argument data in a file with the name fileName.coderdata in your current directory. You can use this function in your host machine to sae the paraleters in a file.
dataFromFile = coder.read(fileName) reads from the fileName.coderdata storage file and returns the data stored within the file. You can use this function in your MATLAB® code for which you want to generate C/C++ code. The generated code performs the data read at run time.
  댓글 수: 2
Yang Renda
Yang Renda 2024년 2월 7일
The thing is, this still creates a separate data file that the host program has to read.
But I am unsure if this data can be compiled to the embedded system, embedded systems are not computers, I cannot just copy the data in, it has to be compiled in.
I will test this and see if it works.
In principle, if the data is just expressed in the form of an array in a c source file as a const, I know that will be compiled inside. So something like this will surely work.
Yang Renda
Yang Renda 2024년 2월 7일
coder.read reads data at run time, which also needs a directory, which means it is meant for some some form of operating system, but an embedded system does not have that. I am highly uncertain whether this can work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by