simulating-simulink-models — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited simulating-simulink-models (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
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.
testing-simulink-modelstesting-simulink-models (requires Simulink Test; auto-creates a harness, compiles only the subsystem — much faster than sim() which always compiles the entire model)Always simulate using Simulink.SimulationInput and Simulink.SimulationOutput:
in = Simulink.SimulationInput('MyModel');
in = in.setModelParameter('StopTime', '10');
out = sim(in);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);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);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);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)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');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.
set_param, load_system, or open_system to drive simulation — SimulationInput replaces all of these.SimulationOutput access in try-catch or isfield — sim either returns a valid object or throws. SimulationOutput has no isfield method.out.logsout.get('name').Values.in/out as variable names for SimulationInput/SimulationOutput.setExternalInput with a Dataset — don't pass comma-separated lists of variables.----
Copyright 2026 The MathWorks, Inc.
----
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.