简体   繁体   中英

How to export Matlab LUT to C code using Embedded Coder?

I have data from Simulink (Lookup tables generated from non-linear functions) 100x100 double array and my goal is to export it in the most efficient way from Matlab to C code so that I can implement it on a microcontroller and perform the interpolation.

I am interested in exporting the variables as opposed to functions which then I can easily use in the C files.

I have tried code generation with Matlab Coder however it is designed for converting Matlab function to C function which is not what I need.

Unfortunately, I haven't worked with Matlab for 10 years, so my answer may not be the best one.

As Jabberwocky already wrote, you might write a simple script that writes something like int foo[] = {... to a file.

Simulink models have a property named PostCodeGenCommand . This property contains a list of Matlab commands and/or scripts to be executed after RTW code generation. And the value (the list of commands) is saved in the Simulink (.mdl) file. Details are described on the MathWorks web site .

If you write the script writing the int foo[] =... in Matlab (.m) instead of C, you may add this script to the PostCodeGenCommand property so it is executed everytime you generate code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM