Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Sanskar
Sanskar il 5 Lug 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!

Più risposte (0)

Categorie

Scopri di più su Deployment, Integration, and Supported Hardware in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by