Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Add, configure, and manage faults on Simulink, Simscape, and System Composer model signals for robustness analysis and safety validation. Use when injecting faults (stuck, noise, gain, offset) onto block inports/outports, enabling fault simulation, or analyzing fault effects. Covers sensor failures, signal corruptions, actuator faults, FMEA validation, and robustness testing. Requires Simulink Fault Analyzer.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 21% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 48% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 88% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -2% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 66% | 0% |
Use evaluate_matlab_code with the Simulink.fault API to programmatically inject faults into Simulink models. Faults override signal values at block ports to simulate hardware failures, sensor faults, and actuator malfunctions.
manage-safety-analysisbuilding-simulink-modelssimulating-simulink-modelstesting-simulink-modelsmatlabhasFA = ~isempty(which('Simulink.fault.addFault')); fprintf('Simulink Fault Analyzer available: %d\n', hasFA);
references/fault-behaviors.md)..slx file containing fault behavior subsystem(s).<ModelName>_faultInfo.xml stores all fault metadata alongside the model.get_param(blockPath, 'PortHandles')._faultInfo.xml files. Always use MATLAB APIs to modify fault definitions.addBehavior) must also be a valid MATLAB identifier.Simulink.fault.deleteAll or Simulink.fault.deleteFault to toggle faults on/off for simulation. Deleting faults destroys fault objects, their behavior models (.slx files), and their traceability links permanently. Use Simulink.fault.injection(model, false) to disable ALL fault injection for a nominal run, and Simulink.fault.injection(model, true) to re-enable. Use Simulink.fault.enable(modelElement, false) to disable faults on specific elements.model_overview and model_read to identify fragile signal paths -- single-point actuators, sensor feedback, computed quantities with wide fan-out.references/preflight-and-adding-faults.md.get_param(blk, 'PortHandles').Simulink.fault.addFault(portHandle, Name=..., Description=...). See references/preflight-and-adding-faults.md.addBehavior(fault, modelName, FaultBehavior='mwfaultlib/...'). See references/fault-behaviors.md.fault.TriggerType and the corresponding properties (e.g., StartTime for Timed, Conditional for Conditional, TriggerActive for Manual). See references/triggers-and-conditionals.md.Simulink.fault.save('ModelName').Simulink.fault.injection(mdl, true) then sim(...). See references/simulation-workflows.md.model_read to identify target blocks before injecting faultsreferences/preflight-and-adding-faults.md)Simulink.fault.save('ModelName') after any fault changesactivate(fault)Simulink.fault.injection(mdl, false)mwfaultlib behaviorSimulink.fault.Fault() constructor -- use Simulink.fault.addFault() insteadmwfaultlib/Stuck-at-Ground) as the fault model name argument to addBehavior -- use the FaultBehavior name-value pairfault.Persistent = true -- it makes the fault irreversible during simulation| Issue | Cause | Fix | |-------|-------|-----| | Assertion failed in Simulink.fault.Fault() | Do not use the Fault() constructor directly | Use Simulink.fault.addFault(portHandle, Name=..., Description=...) instead | | Fault name must follow MATLAB variable naming conventions | Name contains spaces or special chars | Use camelCase/PascalCase with no spaces (e.g., SensorStuckAtZero) | | Invalid name for a fault model | Behavior model name has invalid characters | Use a simple MATLAB identifier (e.g., StuckAtZero, not Stuck-at-Zero) | | Unable to add fault... only to block input or output ports | Passed a block path/handle instead of port handle | Use ph = get_param(blockPath, 'PortHandles'); ph.Outport(1) | | Target signal is a continuous-time signal | Fault Analyzer cannot inject on continuous signals going to continuous blocks | See Continuous-Time Signal Decision Tree in references/advanced-operations.md | | Output dimensions do not match or Data type mismatch | Fault constant size/type ≠ target signal | See "Vector and Matrix Fault Values" in references/fault-behaviors.md | | Bus signal fault fails with non-Ground behavior | Most mwfaultlib behaviors are scalar-only | Use Stuck-at-Ground for full bus, or use BusElement to target individual elements | | Multiple faults on same port but only one fires | Only one fault per port is active at a time | Use activate(fault) to select, or use different StartTime values | | Fault exists but simulation runs nominally | Fault injection not enabled or fault not active | Call Simulink.fault.injection('Model', true) and activate(f) |
| File | Contents | |------|----------| | references/preflight-and-adding-faults.md | Port inspection, compile checks, adding faults, port handle resolution, fault object properties/methods | | references/fault-behaviors.md | Built-in behaviors, custom behaviors, bus faults, vector/matrix faults, discovery, data inport source | | references/triggers-and-conditionals.md | Trigger types, conditional creation, conditional/symbol object properties | | references/simulation-workflows.md | Running simulations, nominal vs. faulted comparison, selective fault isolation | | references/advanced-operations.md | FMEA linking, reports, export, deletion, continuous-time workarounds, synchronizing faults from referenced models/subsystems/libraries | | references/test-case-integration.md | Adding fault sets to Simulink Test cases (R2024a+) |
Copyright 2026 The MathWorks, Inc.
Other measured skills in the registry, with their headline benchmark lift.