Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use this skill whenever simulating a Simulink model, running the sim command, setting up SimulationInput objects, passing input signals via timeseries or datasets, configuring model or block parameters programmatically, or accessing logged output data from SimulationOutput. Trigger for any request involving sim(), Simulink.SimulationInput, Simulink.SimulationOutput, logsout, setExternalInput, or setModelParameter.
.claude/skills/hashgraph-online-simulink-simulation/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 42% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 12% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -7% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 55% | 0% |
Always simulate using Simulink.SimulationInput and Simulink.SimulationOutput:
matlabin = Simulink.SimulationInput('MyModel'); in = in.setModelParameter('StopTime', '10'); out = sim(in);
Never use set_param, load_system, or open_system to drive simulation — the SimulationInput API replaces all of these.
If the MATLAB MCP tool is unavailable but the user explicitly asks for real artifacts such as .slx, exported figures, or .mat results, use local MATLAB execution such as matlab -batch as a fallback. Give MATLAB generous timeouts because startup alone can take minutes.
For MATLAB MCP core server v0.9.0 and newer, this personal plugin launcher can pass through optional session/logging settings via environment variables:
MATLAB_SESSION_MODE -> --matlab-session-modeMATLAB_EXTENSION_FILE -> --extension-fileMATLAB_EXTENSION_FILES -> repeated --extension-file values, separated by the OS path separator (; on Windows)MATLAB_LOG_FOLDER -> --log-folderMATLAB_LOG_LEVEL -> --log-levelMATLAB MCP core server v0.9.2 improves --initialize-matlab-on-startup=true so the MCP server is not blocked while MATLAB starts, and fixes shareMATLABSession() failures on Windows. Keep the launcher default lazy startup unless the user explicitly wants startup-time initialization.
MATLAB MCP core server v0.10.0 makes auto the default session mode. Leave MATLAB_SESSION_MODE unset for normal use, set it to existing only when the user has run shareMATLABSession() in the target MATLAB session, and use multiple extension files only when the current MCP server exposes those custom tools.
Keep MATLAB_SETUP_MATLAB unset for normal MCP sessions; set it only for a one-time upstream setup run.
Use SimulationInput methods to configure the simulation:
matlab% Model-level parameters (StopTime, SolverType, SimulationMode, etc.) in = in.setModelParameter('StopTime', '10', 'SolverType', 'Fixed-step'); % Block parameters in = in.setBlockParameter('MyModel/Gain', '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. Each timeseries Name must match the corresponding Inport block's signal name, otherwise the signal won't be routed correctly.
matlabdt = 0.01; % sample time N = 1000; % Number of points t = dt*(0:N)'; u = sin(2*pi*t); ts = timeseries(u, t); ts.Name = 'mySignal'; % must match the Inport signal name in the model ds = Simulink.SimulationData.Dataset; ds{1} = ts; in = in.setExternalInput(ds); out = sim(in);
Before accessing logged data by name, discover what signals the model actually logs by running a simulation and inspecting logsout:
matlabin = Simulink.SimulationInput('MyModel'); out = sim(in); disp('List of logged signals:'); disp(out.logsout.getElementNames);
This is especially useful when working with an unfamiliar model — the names returned here are exactly the names to use when calling out.logsout.get(...).
Logged signals are available through out.logsout. Access them directly by name — no intermediate variables needed:
matlab% 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)
Do not validate out with try-catch or isfield — sim either returns a valid SimulationOutput or throws an error. Simulink.SimulationOutput has no isfield method.
If the model uses To Workspace blocks and ReturnWorkspaceOutputs is on, retrieve those outputs directly from the SimulationOutput object:
matlabin = Simulink.SimulationInput('MyModel'); in = in.setModelParameter('ReturnWorkspaceOutputs', 'on'); out = sim(in); T = out.simout_T; Q = out.simout_Qbase;
Normalize the exported value before post-processing because To Workspace may return a timeseries, a Simulink.SimulationData.Signal, or a numeric matrix depending on block settings:
matlabif isa(T, 'timeseries') t = T.Time(:); y = T.Data(:); elseif isa(T, 'Simulink.SimulationData.Signal') t = T.Values.Time(:); y = T.Values.Data(:); else t = T(:,1); y = T(:,2); end
When running many simulations, create an array of Simulink.SimulationInput objects using the repmat function instead of looping over sim:
matlabin = 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);
When collecting results from multiple cases into a struct array, preallocate a homogeneous struct shape before the loop. MATLAB will throw "subscripted assignment between dissimilar structures" if later cases add fields or nested layouts that the first element did not have.
To run multiple simulations, use parsim instead of looping over sim:
matlabfor k = 1:N in(k) = Simulink.SimulationInput('MyModel'); in(k) = in(k).setVariable('gain', gains(k)); end out = parsim(in);
If a script repeatedly rebuilds and reruns a model:
close_system, otherwise MATLAB can warn that the changed model cannot be closed.sim and run.sim starts with output-size/type inference errors.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 9,327 | 10,713 | +15% | 1 | 1 | 0% | 1,956 | 2,786 | +42% | 0 | 0 | — |
case-02 | fail→pass | 15,644 | 13,231 | -15% | 1 | 1 | 0% | 2,911 | 3,271 | +12% | 0 | 0 | — |
case-03 | fail→pass | 25,439 | 14,645 | -42% | 1 | 1 | 0% | 3,775 | 3,493 | -7% | 0 | 0 | — |
case-04 | fail→pass | 14,841 | 14,607 | -2% | 1 | 1 | 0% | 2,796 | 3,311 | +18% | 0 | 0 | — |
case-05 | fail→pass | 26,583 | 8,098 | -70% | 1 | 1 | 0% | 1,836 | 2,841 | +55% | 0 | 0 | — |
case-06 | pass→pass | 17,030 | 11,097 | -35% | 1 | 1 | 0% | 2,100 | 3,598 | +71% | 0 | 0 | — |
case-07 | fail→pass | 10,564 | 8,939 | -15% | 1 | 1 | 0% | 1,590 | 2,286 | +44% | 0 | 0 | — |
case-08 | fail→pass | 15,206 | 9,700 | -36% | 1 | 1 | 0% | 1,692 | 2,122 | +25% | 0 | 0 | — |
case-09 | pass→pass | 17,932 | 8,278 | -54% | 1 | 1 | 0% | 1,518 | 2,208 | +45% | 0 | 0 | — |
case-10 | fail→pass | 17,652 | 2,947 | -83% | 1 | 1 | 0% | 2,024 | 2,101 | +4% | 0 | 0 | — |
case-11 | pass→pass | 14,832 | 12,526 | -16% | 1 | 1 | 0% | 2,751 | 2,885 | +5% | 0 | 0 | — |
case-12 | pass→pass | 14,706 | 8,884 | -40% | 1 | 1 | 0% | 1,696 | 3,028 | +79% | 0 | 0 | — |
case-13 | pass→pass | 19,024 | 13,204 | -31% | 1 | 1 | 0% | 2,657 | 3,352 | +26% | 0 | 0 | — |
case-14 | pass→pass | 15,603 | 14,939 | -4% | 1 | 1 | 0% | 1,604 | 3,354 | +109% | 0 | 0 | — |
case-15 | pass→pass | 11,166 | 3,396 | -70% | 1 | 1 | 0% | 1,059 | 2,138 | +102% | 0 | 0 | — |
case-16 | pass→pass | 12,717 | 9,804 | -23% | 1 | 1 | 0% | 2,132 | 2,451 | +15% | 0 | 0 | — |
case-17 | pass→pass | 9,860 | 11,441 | +16% | 1 | 1 | 0% | 1,575 | 2,831 | +80% | 0 | 0 | — |
case-18 | fail→pass | 14,703 | 9,380 | -36% | 1 | 1 | 0% | 1,523 | 2,462 | +62% | 0 | 0 | — |
case-19 | pass→pass | 7,067 | 3,896 | -45% | 1 | 1 | 0% | 1,198 | 2,222 | +85% | 0 | 0 | — |
case-20 | pass→pass | 14,470 | 14,740 | +2% | 1 | 1 | 0% | 1,792 | 3,270 | +82% | 0 | 0 | — |
case-21 | pass→pass | 14,327 | 18,539 | +29% | 1 | 1 | 0% | 2,676 | 4,202 | +57% | 0 | 0 | — |
case-22 | pass→pass | 21,257 | 20,847 | -2% | 1 | 1 | 0% | 2,884 | 4,374 | +52% | 0 | 0 | — |
case-23 | pass→pass | 16,673 | 16,831 | +1% | 1 | 1 | 0% | 2,079 | 3,510 | +69% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +39 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.