Main Content

Simulink.fault.findFaults

Find faults in model

Since R2023b

Description

example

faults = Simulink.fault.findFaults(model) finds the faults in the model, model. The function returns the faults alphabetically by name. If two or more faults on different model elements have the same name, the function returns those faults alphabetically by model element path.

example

faults = Simulink.fault.findFaults(model,property=value) finds the faults filtered by the Fault object property, property, that match the value, value. The function returns complete and partial matches.

example

faults = Simulink.fault.findFaults(model,property1=value1,...,propertyN=valueN) finds the faults filtered by one or more Fault object property values.

Examples

collapse all

Open a model with a block that supports fault modeling.

openExample('simscape_shared/SimpleMotorArmatureWindingFaultExample')

Add two faults to the DC Motor block.

Simulink.fault.addFault(...
"SimpleMotorArmatureWindingFault/DC Motor/Armature winding",...
Name="myFault1");
Simulink.fault.addFault(...
"SimpleMotorArmatureWindingFault/DC Motor/Armature winding",...
Name="myFault2");

Find the faults in the model.

myFaults = Simulink.fault.findFaults("SimpleMotorArmatureWindingFault")
myFaults = 

  1×2 Fault array with properties:

    Name
    Description
    ModelElement
    Type
    IsActive
    TriggerType
    Persistent
    StartTime
    Conditional

Open a model with a block that supports fault modeling.

openExample('simscape_shared/SimpleMotorArmatureWindingFaultExample')

Add two faults to the DC Motor block.

Simulink.fault.addFault(...
"SimpleMotorArmatureWindingFault/DC Motor/Armature winding",...
Name="myFault1");
Simulink.fault.addFault(...
"SimpleMotorArmatureWindingFault/DC Motor/Armature winding",...
Name="myFault2");

Find the faults on the DC Motor block.

myFaults = Simulink.fault.findFaults(...
"SimpleMotorArmatureWindingFault",...
ModelElement="DC Motor/Armature winding")
myFaults = 

  1×2 Fault array with properties:

    Name
    Description
    ModelElement
    Type
    IsActive
    TriggerType
    Persistent
    StartTime
    Conditional

Open a model with a block that supports fault modeling.

openExample('simscape_shared/SimpleMotorArmatureWindingFaultExample')

Add a fault to the Armature winding subelement in the DC Motor block.

myFault = Simulink.fault.addFault(...
"SimpleMotorArmatureWindingFault/DC Motor/Armature winding",...
Name="myFault");

Add an empty behavior to the fault.

addBehavior(myFault,"myBehaviorModel");

Define the TriggerType property for the fault object.

myFault.TriggerType = "Timed";

Find the faults that have the substring Fault in their name and have a timed trigger.

myFaults = Simulink.fault.findFaults(...
"SimpleMotorArmatureWindingFault",...
Name="Fault",TriggerType="Timed")

Input Arguments

collapse all

Path or handle to the model, specified as a string scalar, character vector, or model handle.

Data Types: string | char | double

Name of the property, specified as a property of the Fault object. For more information on Fault object properties, see Fault.

Value of the property, specified in the format determined by the property. You can define this argument by using a regular expression.

Output Arguments

collapse all

Faults in the specified model or model element, returned as a Fault object array.

Version History

Introduced in R2023b