Simscape Diagnose Simulation Error
ASecurityTriage Simscape simulation errors and solver warnings and dispatch to the appropriate diagnostic surface. Covers transient/runtime failures — min step size violations (stiffness, parasitics, event-time), transient initialization failures, and index reduction (\"Cannot solve for one or more variables\"), including errors that appear only with run-time parameters. Use whenever a Simscape model fails to simulate or warns while simulating, even if the user doesn't quote the message and it only sh...
- 1,443 stars
- 0 votes
- 0 copies
- 1 view
- Added November 20, 2026
Works with
Security analysis
100/100Pro scans all 20 files and shows the line behind each finding
npx -y skills add matlab/simulink-agentic-toolkit --skill simscape-diagnose-simulation-error --agent claude-codeAre you the author of Simscape Diagnose Simulation Error?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/matlab-simscape-diagnose-simulation-error)---
name: simscape-diagnose-simulation-error
description: "Triage Simscape simulation errors and solver warnings and dispatch to the appropriate diagnostic surface. Covers transient/runtime failures — min step size violations (stiffness, parasitics, event-time), transient initialization failures, and index reduction (\"Cannot solve for one or more variables\"), including errors that appear only with run-time parameters. Use whenever a Simscape model fails to simulate or warns while simulating, even if the user doesn't quote the message and it only shows up after you run the model or read a warnings log; load it before attempting a fix."
license: https://www.mathworks.com/content/dam/mathworks/license/pmrl/license.md
metadata:
author: MathWorks
version: "0.3.1"
---
Diagnose the simulation error for a Simscape model. In the code below,
`modelName` is the name of that model.
In your answer, quote the tool results your diagnosis rests on (e.g. the
compiled sample times, or the stiffest row with its time, λ and coefficient).
Don't re-run fixes the user says they already tried.
## When to Use
When a Simscape model hits "min step size" violations (stiffness, parasitics, event-time), "transient initialization failed to converge", "Cannot solve for one or more variables, including dynamic variable derivatives", or "stepsize control for transient solve".
## When NOT to Use
- Errors in custom .ssc source (parse, unit, equation count, validation): use `simscape-write-language-code`.
- Building or editing a model that has no simulation error: use `simulink-build-model`.
## Setup
The diagnostic API is bundled with this skill as MATLAB packages under
`scripts/+simscape/+agentic`. Use `evaluate_matlab_code` with `project_path`
set to this skill's `scripts/` folder so MATLAB resolves the
package-qualified calls (e.g. `simscape.agentic.statistics_viewer_run(...)`).
Don't `addpath` `scripts/`. Because `project_path` also makes `scripts/` the
current folder, a model that uses `.ssc` files from its own folder fails to
compile (`Unrecognized function or variable`): `addpath` the model's folder first.
Keep warnings on when you check a fix (use `evalc` to shorten the output
instead): after `warning('off','all')`, Simulink records no warnings, so a fix
that didn't work looks like it did. If the script errors, they stay off for the
rest of the session.
Don't run tight-tolerance "reference" sims to check accuracy: on stiff models
they can take many minutes.
## Triage: Which path to follow?
Messages on large models can run to thousands of characters, with the key phrase buried after long lists of variables or components. Don't read them end-to-end: scan for the keywords below and stop at the first match. Then open the file for that path and follow its steps in order:
- If it mentions **"Event iteration failed to converge within the iteration limit"** → the cause is mode chattering, not a discontinuity or index problem. This skill does not apply. Report to the user that the failing component's mode transition logic is entering an infinite loop and needs review.
- If it mentions **"min step size"** at an event time (Step block firing, mode change), OR **"transient initialization failed to converge"** mid-simulation (not at t=0) → start with the **Discontinuous Inputs** path: [references/discontinuous_inputs_path.md](references/discontinuous_inputs_path.md)
- If it mentions **"high stiffness"**, **"min step size"**, or **"step size control"** and is NOT clearly tied to an event → start with the **Stiffness** path: [references/stiffness_path.md](references/stiffness_path.md)
- If it mentions **"transient initialization failed to converge"** at **t=0**, **"cannot solve for one or more variables"**, or **"problems possible for transient initialization"** → start with the **Index Reduction** path: [references/index_reduction_path.md](references/index_reduction_path.md)
- If none of these match (e.g. an undefined variable or a dimension mismatch) → no path applies. Report the error to the user and fix it directly, without starting a path.
----
Copyright 2026 The MathWorks, Inc.
----
Files in this skill
- SKILL.md
- manifest.yaml
- references/initialization_analyzer.md
- references/nominal_values.md
- references/sps_input_jumps.md
- references/statistics_viewer.md
- references/stiffness_analyzer.md
- references/variable_scaling_analyzer.md
- references/variable_viewer.md
- scripts/+simscape/+agentic/InitializationAnalysis.p
- scripts/+simscape/+agentic/ModelStatistics.p
- scripts/+simscape/+agentic/VariableScaling.p
- scripts/+simscape/+agentic/initialization_analyzer_run.p
- scripts/+simscape/+agentic/nominal_values_get_nominal_values.p
- scripts/+simscape/+agentic/nominal_values_is_nominal_enabled.p
- scripts/+simscape/+agentic/nominal_values_set_nominal_enabled.p
- scripts/+simscape/+agentic/nominal_values_set_nominal_values.p
- scripts/+simscape/+agentic/parasiticParameters.p
- scripts/+simscape/+agentic/private/simscape_debug_progress.p
- scripts/+simscape/+agentic/private/simscape_debug_simplify_unit.p
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.