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
Add Empty Behavior to Fault
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");
Add Noise Behavior to Fault
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
— Fault
Fault
object
Fault, specified as a Fault
object.
faultModel
— File name of fault model
string scalar | character vector
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.
FaultModelDir
— Directory of fault model
string scalar | character vector
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
FaultBehavior
— Fault behavior
"mwfaultlib/Absolute Value"
| "mwfaultlib/Add Noise"
| "mwfaultlib/Gain"
| string scalar | character vector | ...
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
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- 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)