addBehavior
Description
addBehavior(
adds fault behavior to the fault, fault,faultModel)fault, and stores the fault behavior
parameters in the fault model, faultModel.
addBehavior(
adds the fault behavior to the fault using one or more name-value arguments.fault,faultModel,Name=Value)
Examples
Open the fault_analyzer_intro model.
openExample("faultanalyzer/FaultAnalyzerIntroExample")Add a fault to the Sine Wave block.
fault = Simulink.fault.addFault(... "fault_analyzer_intro/Sine Wave/Outport/1");
Assign empty behavior to the fault and store the behavior in a fault model named
myBehaviorModel on the path.
addBehavior(fault,"myBehaviorModel");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 available in the mwfaultlib library to the
fault and store the behavior in a fault model named myBehaviorModel
on the path.
addBehavior(myFault,"myBehaviorModel",... FaultBehavior="mwfaultlib/Add Noise");
Input Arguments
Fault, specified as a Fault object.
File name of the fault model, specified as a string scalar or character vector. The function creates a Fault Subsystem block that models the behavior in this fault model.
For more information on this block and this model, see Investigate the Fault Behavior and Create Predefined and Custom Fault Behaviors.
Data Types: char | string
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: addBehavior(fault,"myBehaviorModel",FaultBehavior="mwfaultlib/Gain")
adds gain behavior to the fault, fault, in the fault model,
myBehaviorModel.
Example: addBehavior(fault,"myBehaviorModel",FaultModelDir="C:\myFiles")
adds behavior to the fault, fault, in the fault model,
myBehaviorModel, and stores the fault model in the
C:\myFiles folder.
Directory of the fault model, specified as a string scalar or character vector. If you enter an empty string or character vector, the function uses the current directory. The directory must exist before you specify it.
Data Types: char | string
Fault behavior, specified as one of these values:
| Value | Description |
|---|---|
"mwfaultlib/Absolute Value" | Sets the signal value to its absolute value when the fault triggers. |
"mwfaultlib/Add Noise" | Adds noise to the signal when the fault triggers. |
"mwfaultlib/Gain" | Adds a gain to the signal when the fault triggers. |
"mwfaultlib/Negate Value" | Multiplies the signal by -1 when the fault
triggers. |
"mwfaultlib/Offset-by-1" | Subtracts -1 from the signal when the fault
triggers. |
"mwfaultlib/Stuck-at-Constant" | Sets the signal to a constant value when the fault triggers. The default
value is 1. |
"mwfaultlib/Stuck-at-Ground" | Sets the signal to zero when the fault triggers. |
"mwfaultlib/Unit Delay" | Applies a unit delay to the signal when the fault triggers. |
| string scalar or character vector | Specify a custom fault behavior in a custom library. |
Simscape™ blocks do not support this name-value argument.
If you do not specify this argument, the function assigns a Fault Subsystem block that contains only a Fault Inport and Fault Outport block. You must add and connect blocks in the Fault Subsystem block before simulating.
To see the fault behaviors you can add, use Simulink.fault.libraryBlocks. You can specify additional fault behaviors
by registering a custom library. When specifying a behavior from a registered custom
library, specify the library name followed a slash and then the behavior name. For
example, if you have a custom library named myLib that contains a
behavior named myBehavior, specify this argument as
"myLib/myBehavior".
For more information on creating and registering custom fault behavior libraries, see Create Predefined and Custom Fault Behaviors.
Data Types: char | string
Since R2026a
Bus element that the fault behavior affects, specified as a string scalar or a character vector. Specify this property only if the fault is assigned to a bus, and specify only one bus element.
Example: addBehavior(fault,"myBehaviorModel",
FaultBehavior="mwfaultlib/Add Noise",BusElement="element1") adds noise
behavior that affects only the element1 bus element. The
fault fault is assigned to a bus that has this bus
element.
Data Types: char | string
Limitations
After you add behavior to a fault, you cannot add additional behavior to the fault.
If you assigned incorrect behavior to the fault, delete
the old behavior with the deleteBehavior function, then add new behavior to the fault.
Version History
Introduced in R2023b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)