Specify whether to generate code for if-elseif-else
decision
logic as switch-case
statements.
This readability optimization works on a per-model basis and applies only to:
Flow charts in Stateflow® charts
MATLAB® functions in Stateflow charts
MATLAB Function blocks in that model
Category: Code Generation > Code Style
Default: on
Generate code for if-elseif-else
decision
logic as switch-case
statements.
For example, assume that you have the following logic pattern:
if (x == 1) { y = 1; } else if (x == 2) { y = 2; } else if (x == 3) { y = 3; } else { y = 4; }
Selecting this check box converts the if-elseif-else
pattern
to the following switch-case
statements:
switch (x) { case 1: y = 1; break; case 2: y = 2; break; case 3: y = 3; break; default: y = 4; break; }
Preserve if-elseif-else
decision logic in
generated code.
Parameter: ConvertIfToSwitch |
Type: character vector |
Value: 'on' | 'off' |
Default: 'on' |
Application | Setting |
---|---|
Debugging | No impact |
Traceability | Off |
Efficiency | On (execution, ROM), No impact (RAM) |
Safety precaution | No impact |