Main Content

Conditional

Create or modify conditionals in models

Since R2023b

Description

Conditional objects represent conditionals. You can modify the conditional by setting the object properties.

Creation

To create a Conditional object:

Properties

expand all

Name of the conditional, specified as a string scalar or character vector. Each conditional name in the model must be unique.

Data Types: char | string

Condition expression, specified as a string scalar or character vector. When you add symbols to the expression, you automatically create Symbol objects. To programmatically adjust the properties of these symbols, retrieve the Symbol objects by using the getSymbols function.

Data Types: char | string

Whether the conditional is logged in the Simulation Data Inspector, specified as a numeric or logical 1 (true) or 0 (false).

Data Types: logical

Object Functions

getSymbolsGet symbols in conditionals
getTriggeredFaultsReturn array of faults triggered by conditional
getAssociatedModelRetrieve name of model fault

Examples

collapse all

Open the fault_analyzer_intro model.

openExample('faultanalyzer/FaultAnalyzerIntroExample')

Create a conditional with the expression y1 > 0.

conditional = Simulink.fault.addConditional(...
"fault_analyzer_intro","myConditional","y1 > 0");

Open the fault_analyzer_intro model.

openExample('faultanalyzer/FaultAnalyzerIntroExample')

Add three conditionals to the model, each with a specific name and expression.

Simulink.fault.addConditional(...
"fault_analyzer_intro","myConditional1","y1 >= 0");
Simulink.fault.addConditional(...
"fault_analyzer_intro","myConditional2","y2 >= 0");
Simulink.fault.addConditional(...
"fault_analyzer_intro","myConditional22","y3 >= 0");

Retrieve the conditionals that contain 2 in the name.

fault_conditionals = Simulink.fault.findConditionals(...
"fault_analyzer_intro",Name="2");

Version History

Introduced in R2023b