Documentation Center

  • Trial Software
  • Product Updates

Contents

db_0159: Flowchart patterns for case constructs

ID: Title

db_0159: Flowchart patterns for case constructs

Priority

Strongly recommended

Scope

MAAB

MATLAB Versions

All

Description

Use the following patterns must be used for case constructs within Stateflow® Flowcharts:

Equivalent FunctionalityFlowchart Pattern

case with exclusive selection

selection = ...; 
switch (selection) 
{      
case 1:          
  action1;      
break;     
case 2:         
  action2;     
break;     
case 3:         
  action3;     
break;     
default:          
  action4; 
} 

Equivalent FunctionalityFlowchart Pattern

case with exclusive conditions

c1 = condition1;  
c2 = condition2;  
c3 = condition3;  
if (c1 && !c2 && !c3)
{      
action1;  
}  
elseif (!c1 && c2 && !c3) 
{      
action2;  
}  
elseif (!c1 && !c2 && c3) 
{      
action3;  
}  
else 
{      
action4;  
} 

Rationale

  • Readability

Last Changed

V1.0

Model Advisor Check

Not applicable

Was this topic helpful?