Main Content

Simulink.fault.enable

Enable or disable faults on model elements

Since R2023b

Description

example

Simulink.fault.enable(modelElements,status) enables or disables the model elements, modelElements, for fault injection based on the value of status.

Examples

collapse all

Open the fault_analyzer_intro model.

openExample('faultanalyzer/FaultAnalyzerIntroExample')

Add a fault to the Sine Wave block output port.

myFault = Simulink.fault.addFault(...
"fault_analyzer_intro/Sine Wave/Outport/1");

Assign noise behavior to the fault and store the behavior in a fault model named myBehaviorModel on the path.

addBehavior(myFault,"myBehaviorModel",...
FaultBehavior="mwfaultlib/Add Noise");

Enable fault injection on the Sine Wave block output port.

Simulink.fault.enable("fault_analyzer_intro/Sine Wave/Outport/1",true)

Input Arguments

collapse all

Paths or handles of model elements, specified as a string array, cell array of character vectors, or a vector of handles. If you specify only one model element, enter it as a scalar.

In Simulink® models, each entry in the array must be the path or handle of a block output or input port. In Simscape™ blocks, each entry in the array must be the path of a fault-capable model subelement. In System Composer™ models, each entry in the array must be the path to a component output or input port.

Example: "myModel/Sine Wave/Outport/1"

Example: ["myModel/Sine Wave/Outport/1" "myModel/Gain/Outport/1"]

Example: {'myModel/Sine Wave/Outport/1', 'myModel/Gain/Outport/1'}

Data Types: string | char | double

Enabled status of model elements, specified as a numeric or logical 1 (true) or 0 (false). Enter 0 or false to disable fault injection on the model elements. Each model element must have at least one fault that has behavior.

Data Types: logical

Version History

Introduced in R2023b