How to have both if and else statement to be present in the generated embedded code of a simulink model?

2 次查看(过去 30 天)
When I am trying to generate the embedded code of a model, the code for if-else block is not generated. If someone can explain why is this happening and how can I make sure that the code is generated for if-else block every time that will help a lot.

采纳的回答

Sanskar
Sanskar 2023-7-5
Hi Harsh!
This problem happens when you use constant blocks as an input to the if else block in Simulink. The embedded coder takes the input as a constant value rather than variable and thus generate the code for either the if statement or else statement.
To solve this problem change the default parameter behaviour of your simulink model from inlined to tunable. This will make values of constant block as variable rather than constant. Thus the embedded code will be generated for both the cases.
Refer to these documentations for more information on optimization and default parameter behavior.
Hope it helps!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deployment, Integration, and Supported Hardware 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by