Inject Faults logo

Inject Faults

OrganizationPopular
matlab
inject-faults

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.

Overview

Publishermatlab
Repositorysimulink-agentic-toolkit
Skill nameinject-faults
Stars
1.2K
Forks
112
Bundled files
7
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 7 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by matlab on GitHub. Read the source before you install it.

Installation

Install the Inject Faults AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/matlab/simulink-agentic-toolkit/tree/main/skills-catalog/verification-validation-and-test/inject-faults
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/matlab/simulink-agentic-toolkit.git /tmp/simulink-agentic-toolkit
mkdir -p .claude/skills
cp -r /tmp/simulink-agentic-toolkit/skills-catalog/verification-validation-and-test/inject-faults .claude/skills/inject-faults
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Inject Faults in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Inject Faults on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Inject Faults is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Fault Injection

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.

When to Use

  • Injecting sensor stuck-at faults, noise, or bias for safety analysis (Simulink, Simscape, System Composer)
  • Validating FMEA failure modes through simulation
  • Testing controller robustness against actuator or sensor failures
  • Adding fault placeholders (without behavior) for FMEA traceability before defining fault logic
  • Configuring fault trigger conditions (timed, conditional, always-on)
  • Creating fault scenarios for automated testing
  • Comparing nominal vs. faulted behavior
  • Linking faults to FMEA failure mode cells
  • Generating fault specification reports
  • Exporting models with embedded fault behavior for teams without Simulink Fault Analyzer
  • Registering custom fault behavior libraries
  • Synchronizing (also called resync / sync / synchronize faults / update fault references) fault information from referenced models, subsystems, or linked libraries into a parent model

When NOT to Use

  • Creating FMEA spreadsheets or safety analysis documents -> use manage-safety-analysis
  • Building or editing model structure -> use building-simulink-models
  • Running standard (non-faulted) simulations -> use simulating-simulink-models
  • Writing pass/fail tests -> use testing-simulink-models

Probe

matlab
hasFA = ~isempty(which('Simulink.fault.addFault'));
fprintf('Simulink Fault Analyzer available: %d\n', hasFA);

Key Concepts

  • Fault: A modification applied to a block port (inport or outport) that overrides the signal value.
  • Fault without Behavior: A placeholder that documents a failure point but cannot be simulated.
  • Fault with Behavior: A fault with an associated behavior model that can be simulated (see references/fault-behaviors.md).
  • Fault Model: The .slx file containing fault behavior subsystem(s).
  • Trigger: When the fault activates (Always On, Timed, Conditional, Manual).
  • Fault Info File: <ModelName>_faultInfo.xml stores all fault metadata alongside the model.

Critical Constraints

  1. Faults attach to block PORTS, not blocks. You must get the port handle via get_param(blockPath, 'PortHandles').
  2. NEVER directly edit _faultInfo.xml files. Always use MATLAB APIs to modify fault definitions.
  3. Fault names must be valid MATLAB identifiers (no spaces, slashes, or special characters). Use camelCase or PascalCase.
  4. The fault behavior model name (first arg to addBehavior) must also be a valid MATLAB identifier.
  5. NEVER use 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.
  6. Not supported: Faults inside Stateflow charts, fault models, or observer models.

Workflow

  1. Understand the model. Use model_overview and model_read to identify fragile signal paths -- single-point actuators, sensor feedback, computed quantities with wide fan-out.
  2. Pre-flight check. Query compiled port properties to confirm signal compatibility. If the model is not already compiled, ask the user before compiling. See references/preflight-and-adding-faults.md.
  3. Get port handles. Faults attach to port handles, not block paths. Use get_param(blk, 'PortHandles').
  4. Add fault. Call Simulink.fault.addFault(portHandle, Name=..., Description=...). See references/preflight-and-adding-faults.md.
  5. Add behavior. Call addBehavior(fault, modelName, FaultBehavior='mwfaultlib/...'). See references/fault-behaviors.md.
  6. Configure trigger. Set fault.TriggerType and the corresponding properties (e.g., StartTime for Timed, Conditional for Conditional, TriggerActive for Manual). See references/triggers-and-conditionals.md.
  7. Save. Call Simulink.fault.save('ModelName').
  8. Simulate. Enable injection with Simulink.fault.injection(mdl, true) then sim(...). See references/simulation-workflows.md.

Guardrails

Always

  • Use model_read to identify target blocks before injecting faults
  • Check compiled port info before creating faults (see references/preflight-and-adding-faults.md)
  • Add behavior BEFORE setting trigger properties
  • Save with Simulink.fault.save('ModelName') after any fault changes
  • Verify fault is active before running faulted simulation with activate(fault)
  • Disable fault injection after analysis with Simulink.fault.injection(mdl, false)
  • Verify test input signals are non-zero at fault injection points
  • Check bus compatibility before choosing a mwfaultlib behavior

Never

  • Use the Simulink.fault.Fault() constructor -- use Simulink.fault.addFault() instead
  • Pass library block paths (e.g., mwfaultlib/Stuck-at-Ground) as the fault model name argument to addBehavior -- use the FaultBehavior name-value pair
  • Assume fault simulation is off -- verify before each nominal run
  • Violate any item in the Critical Constraints section

Ask First

  • Before modifying the design model for any reason (adding blocks, changing sample times, reconnecting signals)
  • Before enabling faults on a model that may be shared (it modifies model behavior)
  • Before deleting existing faults (the behavior model .slx is also deleted)
  • Before enabling fault.Persistent = true -- it makes the fault irreversible during simulation

Troubleshooting

IssueCauseFix
Assertion failed in Simulink.fault.Fault()Do not use the Fault() constructor directlyUse Simulink.fault.addFault(portHandle, Name=..., Description=...) instead
Fault name must follow MATLAB variable naming conventionsName contains spaces or special charsUse camelCase/PascalCase with no spaces (e.g., SensorStuckAtZero)
Invalid name for a fault modelBehavior model name has invalid charactersUse a simple MATLAB identifier (e.g., StuckAtZero, not Stuck-at-Zero)
Unable to add fault... only to block input or output portsPassed a block path/handle instead of port handleUse ph = get_param(blockPath, 'PortHandles'); ph.Outport(1)
Target signal is a continuous-time signalFault Analyzer cannot inject on continuous signals going to continuous blocksSee Continuous-Time Signal Decision Tree in references/advanced-operations.md
Output dimensions do not match or Data type mismatchFault constant size/type ≠ target signalSee "Vector and Matrix Fault Values" in references/fault-behaviors.md
Bus signal fault fails with non-Ground behaviorMost mwfaultlib behaviors are scalar-onlyUse Stuck-at-Ground for full bus, or use BusElement to target individual elements
Multiple faults on same port but only one firesOnly one fault per port is active at a timeUse activate(fault) to select, or use different StartTime values
Fault exists but simulation runs nominallyFault injection not enabled or fault not activeCall Simulink.fault.injection('Model', true) and activate(f)

Reference Files

FileContents
references/preflight-and-adding-faults.mdPort inspection, compile checks, adding faults, port handle resolution, fault object properties/methods
references/fault-behaviors.mdBuilt-in behaviors, custom behaviors, bus faults, vector/matrix faults, discovery, data inport source
references/triggers-and-conditionals.mdTrigger types, conditional creation, conditional/symbol object properties
references/simulation-workflows.mdRunning simulations, nominal vs. faulted comparison, selective fault isolation
references/advanced-operations.mdFMEA linking, reports, export, deletion, continuous-time workarounds, synchronizing faults from referenced models/subsystems/libraries
references/test-case-integration.mdAdding fault sets to Simulink Test cases (R2024a+)

Copyright 2026 The MathWorks, Inc.


Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Inject Faults AI skill do?

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.

Why use Inject Faults on TypingMind?

Because you install it once and use it with any model. Inject Faults is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Inject Faults in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/matlab/simulink-agentic-toolkit/tree/main/skills-catalog/verification-validation-and-test/inject-faults. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Inject Faults?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Inject Faults?

As many as you like. As long as a model supports skills, you can use Inject Faults with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Inject Faults AI skill free?

It is published on GitHub by matlab. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇