Matlab Use Experiment Manager
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Automation and integrations
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The Experiment Manager Assistant enables users to create, modify, and manage experiments within the MATLAB Experiment Manager app through code-driven workflows. It bridges the gap between script-based experiment definition and the graphical user interface, ensuring that changes to experiment parameters, strategies, or project structures are reflected in the Experiment Manager UI in real-time without requiring application restarts.
What it does
- Generates experiment functions from user code or problem descriptions.
- Synchronizes experiment modifications directly with the Experiment Manager UI.
- Supports creation of general-purpose, built-in training, and custom training experiments.
- Facilitates parameter sweeps and strategy configuration.
- Provides lifecycle management including adding, deleting, renaming, and duplicating experiments.
- Integrates with MATLAB's internal API to maintain state consistency.
When to use it
- When you need to create an experiment from existing MATLAB code or a specific problem description.
- When you want to perform parameter sweeps or change experiment strategies programmatically.
- When you need to add, remove, or rename experiments within an active Experiment Manager session.
- When you want to ensure your code-based experiment definitions remain in sync with the visual interface.
Advantages
- Eliminates manual UI configuration for repetitive experiment setup tasks.
- Maintains live synchronization between code definitions and the Experiment Manager browser.
- Supports complex experiment types including Bayesian Optimization and custom training loops.
- Reduces errors by programmatically validating experiment structures and function signatures.
Usage examples
- “Create a new experiment for my parameter sweep using these ranges.”
- The agent analyzes the provided parameters, generates the necessary experiment function, and updates the Experiment Manager UI to reflect the new experiment configuration.
- “Rename my current experiment to 'Optimization_Run_01' and update the learning rate parameter.”
- The agent renames the experiment in the file system and the UI tree, while simultaneously updating the parameter value within the experiment definition.
Install
3 of its files are not mirrored here, so install it from its source:
https://github.com/matlab/matlab-agentic-toolkit/tree/2a7f215e965597acf6ed495beb9e7b8aff45a3be/skills-catalog/ai-and-statistics/matlab-use-experiment-manager
Documentation by MathWorks
Experiment Manager Assistant
Create experiments from user code or problem descriptions AND keep the Experiment Manager (EM) UI in sync — adding/deleting/editing experiments updates the browser tree and editor live, without restarting EM.
When to Use
Use this skill when the user wants to manage an experiment in MATLAB Experiment Manager: create an experiment from a script or description, sweep parameters, add/delete/edit experiments, rename or duplicate an experiment, or ask about an experiment's strategy, parameters, or values — and have any change reflected live in the EM UI.
When NOT to Use
Do not use this skill for requests that are not about managing an Experiment Manager experiment. Hand off instead:
Train, design, or build a neural network →
matlab-train-network.Debug, refactor, or review plain MATLAB code with no experiment →
matlab-debug-code,matlab-modernize-code, ormatlab-review-code.Build an app, dashboard, or GUI from scratch →
matlab-build-app.Make a live script or report →
matlab-create-live-script.Run, monitor, analyze, compare, or export experiment results — this skill provides UI instructions only; it does not perform these itself.
Setup
When this skill is invoked, add the skill's scripts folder to the MATLAB path so that
manageExperimentHelpers is available. Run this via the MATLAB MCP evaluate_matlab_code tool:
addpath('<skill-base-directory>/scripts');This skill manages experiments inside the existing MATLAB Experiment Manager app. It does
NOT design or build new MATLAB apps or GUIs — to build an app, dashboard, or interactive tool
from scratch, use matlab-build-app.
How to use this skill
Always read common.md first. It holds the setup, the shared General Principles, the Modification Flow (Steps 1–5), dirty-state handling, frontend support detection, the EM state model, the API reference, and the validation rules that every operation depends on.
Then open the reference for the specific task the user is asking for.
Tasks
Pick the one operation that matches the request:
| # | Task | Reference |
|---|---|---|
| 1 | Create — from code or description, generate function, open in EM | create.md |
| 2 | Load Project — open project in EM, list experiments, offer actions | load-project.md |
| 3 | Update — modify parameters, strategy, functions, supporting files | update.md |
| 4 | Delete — remove experiment tab, results, tree entry, and file | delete.md |
| 5 | Rename — update name, tree label, and tab title | rename.md |
| 6 | Duplicate — copy with a custom name | duplicate.md |
Two buckets:
Project Management — Load Project, Create
Experiment Management — Update, Rename, Duplicate, Delete
For querying Experiment Manager UI state (answering questions about strategy, parameters, or values), see the Query Experiment State section in common.md.
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md3.7 KiB
- manifest.yaml521 B
- references/common.md22.6 KiB
- references/create.md15.4 KiB
- references/delete.md2.3 KiB
- references/duplicate.md2.6 KiB
- references/load-project.md700 B
- references/rename.md2.6 KiB
- references/update.md14.4 KiB
- scripts/+experiments/+internal/AgentFrontendBridge.p(opens on GitHub)Not mirrored: opens on GitHub963 B
- scripts/+experiments/+internal/AppController.p(opens on GitHub)Not mirrored: opens on GitHub299 B
- scripts/manageExperimentHelpers.p(opens on GitHub)Not mirrored: opens on GitHub2.9 KiB
references/update.md
Operation: Update Experiment
Shared rules, setup, the Modification Flow, validation, and API are in common.md. Read it first.
Modify an experiment's parameters, strategy, functions, metrics, or supporting files, and keep the UI in sync.
Reply wording (do this every time).
HyperTablebelow is an internal field name used only in the code you run — it must NEVER appear in your reply to the user. When you talk to the user, call it "the parameter values" or "the parameter table". Say "I'll read the current parameter values", not "I'll read the HyperTable". This applies to all narration, before/during/after the update.
Pre-check (Steps 2-3)
IMPORTANT: ALWAYS call getActiveTab() FIRST, before any other operation (before
reading .mat state, before refreshing, before modifying). The active tab determines the
target experiment. Do NOT call refreshOrOpenExperiment or any other method that could
change focus before querying the active tab.
Call
getActiveTab()to resolve which experiment (active tab if not specified)Check dirty state BEFORE modifying — attempt
refreshOrOpenExperiment. If it returnsstatus: 'error'with "unsaved changes", follow the dirty state handling procedure (common.md) (save UI first, then apply modification, then refresh). Do NOT skip this step and modify the .mat file directly — even if the update "succeeds", the UI may overwrite your change when it saves its stale state later.Run
manageExperimentHelpers.validate(expFile)— surface and fix issues firstValidate field names with exact case-sensitive match
Confirm (Step 4)
Show before → after: "Alpha: [1,2,3] → [1,5,7]. Proceed?"
Execute (Step 5)
clear classes
expFile = '<expFile>';
modifications = struct();
modifications.HyperTable = {
{'<ParamName1>'; '<new_values>'; 'real'; 'none'};
{'<ParamName2>'; '<new_values>'; 'real'; 'none'};
};
result = manageExperimentHelpers.update(expFile, modifications);
disp(result);
% Sync
result = experiments.internal.AppController.refreshOrOpenExperiment(expFile);
disp(result);Keeping the function in sync with parameters
IMPORTANT: Every time a parameter is added or removed from the HyperTable (or RandomSamplingData), you MUST also update the experiment function file to match:
Adding a parameter: Add
params.<newParam>usage in the function. Choose a sensible place to use it (e.g., as an argument to a relevant function call or assignment).Removing a parameter: Remove all
params.<removedParam>references from the function.
The function and the parameter list must always be consistent. A parameter in the HyperTable
that is never referenced in the function is useless. A params.X reference in the function
without a matching HyperTable entry will error at runtime.
CRITICAL: Live Script (.mlx) functions — never rewrite their content. Before editing a
function file's content, check its extension. A .mlx is a binary (OOXML/ZIP) file: reading
it as text yields garbage and writing text back corrupts it — the Live Script no longer
opens ("Could not open source package"). writelines/readlines on a .mlx is destructive.
There is no supported in-place code-write API (matlab.internal.setCode does not exist).
So when the experiment's function file is a .mlx:
Do not edit it with
writelines. Do not attempt a format round-trip.You MAY read its current code (non-destructive) to show the user:
code = matlab.internal.getCode('<functionFile>.mlx');Make the
.mat/parameter-table change as normal, then stop and give the user the exact edit to make themselves in the Live Editor (whichparams.Xline to add or remove, and where), rather than editing the file. Then refresh the UI.
This applies only to editing function content. Renaming a .mlx function is safe (the file
is moved as-is, not rewritten) — see rename.md.
CRITICAL: Shared function check. Before modifying an experiment function file, check if
any OTHER experiment in the project uses the same function (by scanning all .mat files'
Process.FunctionSection). If the function is shared by multiple experiments, do NOT modify
it. Instead, stop and ask the user how to proceed (e.g., create a separate function copy for
this experiment, or skip the function update).
After updating the function file, refresh the UI.
Modifying parameters (ExhaustiveSweep / HyperTable)
Pass the full updated HyperTable cell array in modifications.HyperTable.
To add a parameter, append to the array. To remove, omit it.
Always write 4-column rows {Name; Values; Type; Transform} (Type 'real'/'integer'/
'categorical', Transform 'none'/'log') — even in Exhaustive Sweep. Experiment Manager
appends a hidden row id at a fixed column position that assumes all four columns exist; a
2-column row makes the UI's strategy switch (Exhaustive ↔ Random Sampling) mis-map ids and
collapse every parameter to a single name.
Modifying parameters (RandomSampling)
clear classes
expFile = '<expFile>';
modifications = struct();
modifications.RandomSamplingData.params(1).Name = '<ParamName1>';
modifications.RandomSamplingData.params(1).Dist = 'Uniform';
modifications.RandomSamplingData.params(1).properties = struct( ...
'Characteristic', {'Lower'; 'Upper'}, ...
'value', {'0'; '1'});
modifications.RandomSamplingData.params(2).Name = '<ParamName2>';
modifications.RandomSamplingData.params(2).Dist = 'Uniform';
modifications.RandomSamplingData.params(2).properties = struct( ...
'Characteristic', {'Lower'; 'Upper'}, ...
'value', {'1'; '10'});
modifications.RandomSamplingData.nTrials = 25;
result = manageExperimentHelpers.update(expFile, modifications);
disp(result);CRITICAL — Characteristic names must match makedist. The Characteristic values are
passed verbatim as the name-value arguments to makedist(Dist, ...) when the experiment is
validated or run. They are NOT free-form labels — they must be the exact constructor parameter
names for that distribution, or validation fails with Invalid parameter name and the
experiment cannot run. The write itself always succeeds (the helper does not check them), so
always run manageExperimentHelpers.validate after the update to catch a bad name.
Never hardcode the parameter names from memory. Different distributions use different
names (e.g. Normal uses mu/sigma, NOT Mean/Sigma). Look up the correct names at
runtime before building the properties struct:
makedist('<Dist>').ParameterNames % e.g. makedist('Normal') -> ["mu" "sigma"]Common examples (verify with the line above rather than trusting this table):
| Dist | Characteristic names |
|---|---|
Uniform | Lower, Upper |
Normal | mu, sigma |
Lognormal | mu, sigma |
Exponential | mu |
Poisson | lambda |
IMPORTANT: Field name is nTrials (NOT numTrials or NumTrials).
IMPORTANT: Every params entry MUST include a Name field matching the corresponding
HyperTable parameter name. Without Name, the parameter appears unnamed in the UI.
IMPORTANT: After modifying any RandomSampling parameter distribution, ALWAYS expand the modified parameter row(s) for visual feedback:
result = experiments.internal.AppController.expandParameter(expFile, '<ParamName>');
disp(result);Do this for each parameter whose distribution was changed.
Switching experiment type
clear classes
expFile = '<expFile>';
modifications = struct();
modifications.ExperimentType = 'RandomSampling';
result = manageExperimentHelpers.update(expFile, modifications);
disp(result);IMPORTANT: The API value for Exhaustive Sweep is 'ParamSweep' — do NOT use 'ExhaustiveSweep' (crashes editor).
Valid API values:
General purpose:
'ParamSweep'(Exhaustive Sweep),'RandomSampling'Training:
'ParamSweep'(Exhaustive Sweep),'RandomSampling','BayesOpt'
IMPORTANT: Before switching experiment type, check if the target type is valid for the experiment's template type. If the user requests BayesOpt on a general purpose experiment, do NOT apply the change. Instead, refuse and explain that BayesOpt is only available for training experiments, then ask if they'd like Exhaustive Sweep or Random Sampling instead.
When switching to 'RandomSampling', MUST also include RandomSamplingData with params
and nTrials. When switching to Random Sampling for the first time (no existing
RandomSamplingData in the .mat file), use Uniform distribution with Lower=0 and Upper=1
as defaults for all parameters. When switching back to Random Sampling (existing
RandomSamplingData is present), preserve the previously configured distributions and values.
When switching to 'BayesOpt', MUST include BayesOptOptions AND update the
HyperTable to 4-column format.
IMPORTANT: BayesOpt requires HyperTable entries with 4 columns: {Name; Range; Type; Transform}.
Type:
'real','integer', or'categorical'Transform:
'none'or'log'(use'log'for parameters spanning orders of magnitude, e.g., learning rates)
If the current HyperTable only has 2 columns (Name, Range), you MUST add Type and Transform columns when switching to BayesOpt. Otherwise the UI will show empty Types and Transforms.
Exhaustive Sweep / RandomSampling → BayesOpt:
clear classes
expFile = '<expFile>';
modifications = struct();
modifications.ExperimentType = 'BayesOpt';
modifications.HyperTable = {
{'<ParamName1>'; '[lower, upper]'; '<type>'; '<transform>'};
{'<ParamName2>'; '[lower, upper]'; '<type>'; '<transform>'};
};
modifications.BayesOptOptions.MaxExecutionTime = 'Inf';
modifications.BayesOptOptions.MaxTrials = '30';
modifications.BayesOptOptions.XConstraintFcn = '';
modifications.BayesOptOptions.ConditionalVariableFcn = '';
modifications.BayesOptOptions.AcquisitionFunctionName = 'expected-improvement-plus';
result = manageExperimentHelpers.update(expFile, modifications);
disp(result);Renaming the experiment function
Renaming the function is more than a .mat field change: the .m file on disk and its
function signature must also be renamed. The renameFunction helper does all of it —
renames the file, rewrites the signature, sets Process.FunctionSection, and re-adds the
file to the project.
clear classes
result = manageExperimentHelpers.renameFunction('<expFile>', '<oldName>', '<newName>'); disp(result);
result = experiments.internal.AppController.refreshOrOpenExperiment('<expFile>'); disp(result);IMPORTANT: Do NOT try to rename the function through manageExperimentHelpers.update —
it only edits fields inside the .mat file and cannot touch the .m file. Use
renameFunction.
Adding post-training custom metrics (training experiments only)
Post-training custom metrics are function files that compute a scalar value after training
completes. They receive trialInfo with fields: trainedNetwork, trainingInfo, parameters.
Steps:
Write the metric function file to the project folder
Add it to the MATLAB project
Set
Process.Metricsdirectly in the .mat file (the helper doesn't support this field)
clear classes
projectPath = '<projectPath>';
expFile = '<expFile>';
% 1. Write metric function
metricCode = {
'function metricOutput = <metricName>(trialInfo)'
'% Post-training custom metric'
'metricOutput = 0;'
'end'
};
writelines(strjoin(metricCode, newline), fullfile(projectPath, '<metricName>.m'));
prj = currentProject;
addFile(prj, fullfile(projectPath, '<metricName>.m'));
% 2. Set in .mat file (MUST use nested cell array format)
s = load(expFile);
s.Experiment.Process.Metrics = {{'<metricName>'}};
save(expFile, '-struct', 's');
% 3. Refresh UI
result = experiments.internal.AppController.refreshOrOpenExperiment(expFile);
disp(result);IMPORTANT: Process.Metrics must be a nested cell array: {{'metric1'}; {'metric2'}}.
Using {'metric1'} (flat cell) will display only the first character. This is because the
UI iterates the outer cell and expects each element to be a cell containing the function name.
Adding an initialization function to an existing experiment
clear classes
expFile = '<expFile>';
initCode = {
'function output = <initFunctionName>()'
'% Initialization function for <ExperimentName> experiment'
'output = struct();'
'end'
};
result = manageExperimentHelpers.addInitializationFunction(expFile, '<initFunctionName>', initCode); disp(result);
% Refresh UI
result = experiments.internal.AppController.refreshOrOpenExperiment(expFile);
disp(result);IMPORTANT: The correct field is Process.InitializationFunctionValue. Do NOT use
Process.InitializationSection — that field is not consumed by the frontend or backend.
IMPORTANT: When adding an initialization function, you MUST also update the experiment
function, setup function, or training function to access the init output via
params.InitializationFunctionOutput. This applies to ALL experiment types:
General purpose (experiment function):
function output = myExperiment(params)
data = params.InitializationFunctionOutput;
output.result = data.someField * params.k;
endBuilt-in training (setup function):
function [imdsTrain,layers,lossFcn,options] = mySetup(params)
data = params.InitializationFunctionOutput;
imdsTrain = data.imdsTrain;
...
endCustom training (training function):
function output = myTraining(params, monitor)
data = params.InitializationFunctionOutput;
trainingData = data.trainingData;
...
endWithout this, the init function runs but its output is never used.
.mlx functions: if the experiment function to be wired up is a Live Script (.mlx), do
NOT rewrite it (see the Live Script warning under "Keeping the function in sync with
parameters" — a text write corrupts it). Add the init function and set
Process.InitializationFunctionValue as usual, then tell the user the exact
params.InitializationFunctionOutput line to add in the Live Editor themselves.
Adding/removing supporting files
clear classes
expFile = '<expFile>';
% Verify file exists FIRST: isfile(fullfile('<projectPath>', '<fileName>.m'))
modifications = struct();
modifications.SupportingFiles = struct('filePath', '<fileName>.m', 'isRelativePath', true);
result = manageExperimentHelpers.update(expFile, modifications);
disp(result);Copyright 2026 The MathWorks, Inc.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/ai-and-statistics/matlab-use-experiment-manager · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks.
Get it from the source
3 of this skill’s files are not mirrored here, so there is no ZIP. Get the complete skill from its source: matlab/matlab-agentic-toolkit