Generate C code for 'load ' function using MATLAB Coder

9 ビュー (過去 30 日間)
Pankaja Tanjore
Pankaja Tanjore 2015 年 9 月 14 日
コメント済み: Dhruv Thakkar 2021 年 9 月 16 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 9 月 14 日
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.
  1 件のコメント
Dhruv Thakkar
Dhruv Thakkar 2021 年 9 月 16 日
Is this possible with 2021a(July Update)?

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

カテゴリ

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

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by