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 a model with a block that supports fault modeling.

openExample('simscape_shared/SimpleMotorArmatureWindingFaultExample')

Create a conditional with the expression y1 > 0.

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

Open a model with a block that supports fault modeling.

openExample('simscape_shared/SimpleMotorArmatureWindingFaultExample')

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

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

Retrieve the conditionals that contain 2 in the name.

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

Version History

Introduced in R2023b