Use #define values from a Matlab function

2 ビュー (過去 30 日間)
Marcos Barcelo
Marcos Barcelo 2022 年 8 月 7 日
回答済み: Fangjun Jiang 2022 年 8 月 8 日
I'm working on a Stateflow chart (C action language) to generate some code.
When I call an external C function from the chart, I can use the #define values from my C code and it works fine. For example:
resut = my_function(2, MAX_NUMBER);
where MAX_NUMBER is defined in my external C code as
#define MAX_NUMBER 10
However, when I call the same C function from a Matlab Function using coder.ceval, it doesn't know what MAX_NUMBER is:
result = coder.ceval('my_function', 2, MAX_NUMBER);
Is there a way to make this work without having to redefine each value?

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2022 年 8 月 8 日
You might need to add the C header file and source C code file to the model,
Ctrl+E, Simulation Target,
Follow the example in the document
web(fullfile(docroot, 'simulink/slref/coder.ceval.html'))

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by