Convert if-elseif-else patterns to switch-case statements
Generate code for if-elseif-else logic as switch-case statements
Model Configuration Pane: Code Generation / Code Style
Description
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
Settings
on
(default) | off
Default: on
- On
Generate code for
if-elseif-else
decision logic asswitch-case
statements.- Off
Preserve
if-elseif-else
decision logic in generated code.
Examples
Recommended Settings
Application | Setting |
---|---|
Debugging | No impact |
Traceability | Off |
Efficiency | On (execution, ROM), No impact (RAM) |
Safety precaution | No impact |
Programmatic Use
Parameter: ConvertIfToSwitch |
Type: character vector |
Value: 'on' | 'off' |
Default: 'on' |
Version History
Introduced in R2009b