Code Generation (Embedded Coder) The function has no return value?

8 ビュー (過去 30 日間)
Youyi Zhang
Youyi Zhang 2016 年 4 月 11 日
回答済み: Robert 2016 年 4 月 11 日
All generated function in the C files is void. How can I set a return value such as 'return a'?
Thanks!!!

回答 (1 件)

Robert
Robert 2016 年 4 月 11 日
By default, the outputs are assigned via the pointers that are passed into the function. If your model outputs a, you should see a pointer to a in the function inputs, which will be set within the function.
You have some ability to override this via the configuration settings of your model. Look at the Code Generation/Interface settings. There is a button with the text Configure Model Functions that will help you specify outputs as returned arguments and not input pointers.
If you haven't used this window before, select "Model specific C prototypes" from the first dropdown, then press "Get Default Configuration" to populate the rest of the dialog. The resulting table of parameters will include a column labeled "Category" that lets you swap pointers for values. Use value for anything you want passed by value rather than pointer.

カテゴリ

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