Why is there no "if" condition for a "switch" block in generated code?
I am using MATLAB R2024a with Embedded Coder. In my Simulink model, I have a "Switch" that chooses between two signals. I found the code for the "Switch" block in the generated code. However, it does not contain an "if" statement, and it always sets the output signal to the same value:
/* Switch: '<Root>/Switch' incorporates:
* Inport: '<Root>/In1'
*/
outSignal = myInput1;
I want the code to switch between the two signals I send into the "Switch" block like so:
/* Switch: '<Root>/Switch' incorporates:
* Inport: '<Root>/In1'
* RelationalOperator: '<S1>/Compare'
*/
if (controlSignal) < 0)
{
/* Switch: '<Root>/Switch' incorporates:
* Inport: '<Root>/In1'
*/
outSignal = myInput1;
}
else
{
/* Switch: '<Root>/Switch' incorporates:
* Inport: '<Root>/In2'
*/
outSignal = myInput2;
}
Why is the code missing the "if" condition? Is this a bug?
Accepted Answer
More Answers (0)
Categories
Find more on Execution Speed in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!