mcpbeat Sign in

Simulating Simulink Models Agent Skill

Runs Simulink models programmatically for data exploration, parameter sweeps, and custom analysis using sim() with SimulationInput/SimulationOutput. Use when calling sim(), parsim, setExternalInput, setModelParameter, setVariable, or accessing logsout — any task producing simulation results for analysis (not pass/fail tests).

1k tokens
context cost
the whole folder, loaded on every use
2
files
instructions only
0
copies elsewhere
how many repositories repackaged it
900
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/matlab/simulink-agentic-toolkit --skill simulating-simulink-models

The instruction itself

11 sections, as written by the author

Use this skill to generate simulation results for analysis. For persistent, reusable pass/fail behavioral testing (especially of individual subsystems), use testing-simulink-models instead.

When to Use

  • Running a Simulink model from a MATLAB script
  • Configuring simulation parameters (StopTime, solver, etc.) programmatically
  • Passing input signals to root-level Inport blocks
  • Accessing logged signal data after simulation
  • Running parameter sweeps or batch simulations

When NOT to Use

  • Writing declarative Gherkin-based tests → use testing-simulink-models
  • Testing an individual subsystem or component → use testing-simulink-models (requires Simulink Test; auto-creates a harness, compiles only the subsystem — much faster than sim() which always compiles the entire model)

Minimal working pattern

Always simulate using Simulink.SimulationInput and Simulink.SimulationOutput:

in = Simulink.SimulationInput('MyModel');
in = in.setModelParameter('StopTime', '10');
out = sim(in);

Setting parameters

Use SimulationInput methods to configure the simulation:

% Model-level parameters (StopTime, SolverType, SimulationMode, etc.)
in = in.setModelParameter('StopTime', '10', 'SolverType', 'Fixed-step');

% Block parameters — resolve path from blk_X ID (never type block names manually)
blkPath = Simulink.ID.getFullName('MyModel:5');
in = in.setBlockParameter(blkPath, 'Gain', '5');

% MATLAB workspace variables used by the model
in = in.setVariable('Kp', 1.2);

Input signals

Pass input signals through Inport blocks using a Simulink.SimulationData.Dataset. Elements are matched to Inport blocks by index position — the first element maps to the Inport with port number 1, the second to port number 2, and so on.

dt = 0.01;
N = 1000;
t = dt*(0:N)';
u = sin(2*pi*t);

ts = timeseries(u, t);

ds = Simulink.SimulationData.Dataset;
ds{1} = ts;

in = in.setExternalInput(ds);
out = sim(in);

You can also use timetable as an input format:

secs = seconds(t);
tt = timetable(secs, u);

ds = Simulink.SimulationData.Dataset;
ds{1} = tt;

in = in.setExternalInput(ds);

Discovering logged data

First, discover what kinds of logged data the model produces using who, then inspect signal names within logsout:

in = Simulink.SimulationInput('MyModel');
out = sim(in);

% See what logging properties exist (logsout, yout, tout, etc.)
who(out)

% List individual signal names within logsout
disp(out.logsout.getElementNames);

Accessing logged data

Logged signals are available through out.logsout. Access them directly by name:

% Plot a logged signal
plot(out.logsout.get('signalName').Values)

% Get time and data separately
sig = out.logsout.get('signalName').Values;
plot(sig.Time, sig.Data)

Multiple simulations

When running many simulations, create an array of Simulink.SimulationInput objects:

in = repmat(Simulink.SimulationInput('MyModel'),N,1);
for k = 1:N
    in(k) = Simulink.SimulationInput('MyModel');
    in(k) = in(k).setVariable('gain', gains(k));
end
out = sim(in);

To enable fast restart for iterative sweeps (compiles the model only once):

out = sim(in, 'UseFastRestart', 'on');

Parallel simulation (parsim)

To run multiple simulations in parallel, use parsim instead of looping over sim:

for k = 1:N
    in(k) = Simulink.SimulationInput('MyModel');
    in(k) = in(k).setVariable('gain', gains(k));
end
out = parsim(in);

parsim also supports 'UseFastRestart','on' for faster batch runs.

Guardrails

  • Never use set_param, load_system, or open_system to drive simulation — SimulationInput replaces all of these.
  • Never wrap SimulationOutput access in try-catch or isfieldsim either returns a valid object or throws. SimulationOutput has no isfield method.
  • Never create unnecessary intermediate variables for logged data — access directly via out.logsout.get('name').Values.
  • Always use in/out as variable names for SimulationInput/SimulationOutput.
  • Always use setExternalInput with a Dataset — don't pass comma-separated lists of variables.

----

Copyright 2026 The MathWorks, Inc.

----

Other skills for the same job

different authors, same section of the catalogue
Webapp Testing
by anthropics
vendor ×12

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

6k tokens scripts
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
Test Driven Development
by w95
×7

Use when implementing any feature or bugfix, before writing implementation code

2k tokens
Systematic Debugging
by ratacat
×7

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes

10k tokens scripts
Verification Before Completion
by ZhanlinCui
×6

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

1k tokens
Backtest Expert
by BaggaT236
×3

Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.

15k tokens scripts
Adaptyv
by christophacham
×3

Cloud laboratory platform for automated protein testing and validation. Use when designing proteins and needing experimental validation including binding assays, expression testing, thermostability measurements, enzyme activity assays, or protein sequence optimization. Also use for submitting experiments via API, tracking experiment status, downloading results, optimizing protein sequences for better expression using computational tools (NetSolP, SoluProt, SolubleMPNN, ESM), or managing protein design workflows with wet-lab validation.

16k tokens
Aeon
by christophacham
×3

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

19k tokens

How to use it

Copy the folder

Take matlab/simulating-simulink-models from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.