Clear Filters
Clear Filters

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

2 views (last 30 days)
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.

Accepted Answer

Sanskar
Sanskar on 5 Jul 2023
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!

More Answers (0)

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!