Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

db_0159: Flow chart patterns for case constructs

ID: Title

db_0159: Flow chart 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® flow charts:

Equivalent FunctionalityFlow Chart Pattern

case with exclusive selection

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

Equivalent FunctionalityFlow Chart 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

Introduced in R2010a

Was this topic helpful?