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_0114: Simulink patterns for If-then-else-if constructs

ID: Title

db_0114: Simulink® patterns for If-then-else-if constructs

Priority

Strongly recommended

Scope

MAAB

MATLAB Versions

All

Prerequisites

None

Description

Use the following patterns for If-then-else-if constructs within a Simulink model:

Equivalent FunctionalitySimulink Pattern

if then else if with blocks

if (If_Condition) { 
output_signal = If_Value;  
}
else if (Else_If_Condition) { 
output_signal = 
Else_If_Value;
}
else { 
output_signal = 
Else_Value;
} 

Equivalent FunctionalitySimulink Pattern

if then else if with if/then/else subsystems

if(Fault_1_Active &
Fault_2_Active) 
{    
  ErrMsg = SaftyCrit; 
}
else if (Fault_1_Active |
Fault_2_Active)
{    
  ErrMsg = DriveWarn; 
}
else 
{    
  ErrMsg = NoFaults; 
}

Rationale

  • Readability

Last Changed

V2.0

Model Advisor Check

Not applicable

Introduced in R2010a

Was this topic helpful?