Generate C code for 'load ' function using MATLAB Coder

2 visualizzazioni (ultimi 30 giorni)
Hello,
I need to generate the C code using MATLAB coder. If i see the list of functions that are supported in MATLAB 2015a , i found that this function (i.e load)is suppoted for C code generation.
There i found in the remarks that " Use only when generating MEX or code for Simulink® simulation. To load compile-time constants, use coder.load".
I was not clear with this . So can you please give me an example code for load() to generate C code using MATLAB C coder.
Looking forward to hear from you.
Thanks Pankaja

Risposte (1)

Walter Roberson
Walter Roberson il 14 Set 2015
MATLAB Coder is very restricted in the code that it will generate that does run-time file I/O. Only a few of the Standard C library routines are supported.
If you are using Coder to generate mex or for Simulink in some of the Accelerator modes, then, then you are implicitly generating code that can call upon I/O routines that are either in memory (from the MATLAB session) or will have implicit access to MCR; these modes can only be used where there is an existing MATLAB or MCR, not for general systems that do not have either such as embedded systems.
If you are building data tables and want to do the equivalent of #include to bring them in at the time of code generation, then use coder.load() . These are not for run-time load.
If you want to use load() to load a text data file, then you will need to write the code in terms of the supported I/O routines such as fopen(). If you want to use load() to load a MATLAB .mat data file, then you would need to write (or find) C code to parse the binary files yourself. Mathworks does not provide any way to read .mat files at runtime.

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by