matlab/matlab-create-experiment
> Create an experiment for the MATLAB Experiment Manager app from user code, script, or problem description. or hyperparameters, asks to compare configurations, or describes a problem suitable for experimentation. or already has a working experiment set up.
npx skills add https://github.com/matlab/matlab-agentic-toolkit --skill matlab-create-experiment
Plans and creates experiments in MATLAB Experiment Manager by analyzing user code or problem
descriptions, determining the experiment type, and generating the appropriate experiment
function, hyperparameter table, and experiment object.
This skill follows a guidance + autonomy pattern. Decision points are tagged:
| Tag | Meaning |
|-----|---------|
| [user] | Always pause and ask. Non-negotiable. |
| [auto] | Agent decides silently. Escalates on failure. |
| [depends] | Resolved by clarity of signals — auto if clear, ask if ambiguous. |
After analysis, tell the user how you intend to work in one plain sentence.
Always add: "Let me know if you'd prefer more or less control."
Read the user's code or problem description and classify the experiment type.
Classify into one of three types using API-level and semantic signals.
IMPORTANT: If semantic signals indicate training (even without explicit DL API calls),
classify as training — NOT general purpose.
| Type | Signals | Template class |
|------|---------|----------------|
| General purpose | No DL functions, no training indicators. Optimization, simulation, data analysis. | 'experiments.internal.experimentTemplates.MATLABFunction' |
| Built-in training | Uses trainnet/trainNetwork/trainingOptions, standard layers, datastores. OR: file name contains "train", user mentions "classification"/"transfer learning". | 'experiments.internal.experimentTemplates.BlankTrainnetTraining' |
| Custom training (custom loop) | Uses dlnetwork/dlfeval/dlgradient/dlarray, manual gradients, GANs. OR: training loop with loss computation, user mentions "fine-tune"/"detector". | 'experiments.internal.experimentTemplates.CustomTraining' |
| Variable | Tag | Notes |
|----------|-----|-------|
| Experiment type | [depends] | Auto if signals are clear; ask if ambiguous |
| Parameters to sweep | [depends] | Auto-infer from hardcoded values; ask if unclear |
| Parameter values | [auto] | Suggest 2-3 alternatives around hardcoded values |
| Init function needed | [auto] | Yes if expensive ops independent of params detected |
| Function signature | [auto] | Determined by type (see REFERENCES.md) |
Exit criteria: type classified, parameters identified, outputs known.
Generate the experiment function and prepare the full design for user review.
parameters being swept, outputs captured per trial, and evaluation criterion.
[auto] Warn if total trials > 50 (suggest reducing values)| Type | Signature |
|------|-----------|
| General purpose | [out1, out2, ...] = func(params) |
| Built-in (Form A, targets in datastore) | [trainingData, net, lossFcn, options] = func(params) |
| Built-in (Form B, targets separate) | [trainingData, targets, net, lossFcn, options] = func(params) |
| Custom training | output = func(params, monitor) |
Last 3 outputs for built-in must always be net, lossFcn, options.
See references/REFERENCES.md for Form A vs B selection guide and supported loss functions.
Heading convention when presenting:
Key rules:
params.<field> for all tunable values (never hardcode swept values)params.<field> is a single scalar value (numeric, string, or logical) — Experiment Manager assigns one value per trial. Never loop over parameter values inside the function; the sweep is handled externally.'Plots', 'none' in trainingOptions| Type | Body contains | Returns |
|------|--------------|---------|
| General purpose | User's computation logic, including figure/plot code | Named outputs (any serializable type) |
| Built-in training | Data loading, network definition, trainingOptions | [data..., net, lossFcn, options] |
| Custom training | Training loop with monitor integration, including figure/plot code | output (any serializable type) |
[auto] Initialization function — If expensive one-time operations independent ofhyperparameters are detected (data downloads, large file loads, datastores not depending
on params), extract into an initialization function.
See references/REFERENCES.md § "Initialization Function Template" for the code template.
[user] — Present design for review before execution.MANDATORY: Always present the design and wait for explicit user confirmation before creating any files or running any MATLAB code. Never skip this gate, even if the user has confirmed similar experiments before. The only exception is if the user explicitly says to skip confirmation (e.g., "just create it without asking").
Presentation order matters:
Do NOT show the summary table before the function code.
Summary table:
| Topic | Details |
|-------|---------|
| Experiment type | <type chosen and why> |
| Parameters/Hyperparameters | <comma-separated list> |
| Total trials | <number> |
| Function name | <functionName> |
| Initialization function | <initFunctionName> if generated, otherwise reason why not |
| Key metric | <metric name> (<minimize/maximize>) |
| Logged live metrics | <comma-separated list> |
Proceed to Phase 4 only after user confirms.
Execute the experiment setup in MATLAB.
[auto]currentProject — if open, use it; otherwise create a new projectcurrentProject succeeds, always use that project — write the experiment function and .mat file into its root folder. Only call matlab.project.createProject when no project is open.matlab.project.createProject changes pwd — use pwd directly after, don't prepend folderwritelines AFTER project exists_2, _3) when creating new projectsSee references/REFERENCES.md § "Step 6 Code Template" for the full code.
[auto]Use the createExperiment helper (in scripts/). It handles:
[auto]Before running validation, briefly tell the user what it checks: "I'm validating that the function exists on path, passes static analysis, has the correct signature, and that its parameter references match the hyperparameter table."
Path portability check: Before validation, scan for relative file paths in the
generated function. If found, resolve to absolute and rewrite.
Run tiered validation (see REFERENCES.md § "Validation"):
which()checkcode(). Block on severity > 1 (errors). Warn on severity ≤ 1.nargin and nargout match the experiment type:general: nargin=1, nargout≥1builtin_A: nargin=1, nargout=4builtin_B: nargin=1, nargout=5custom: nargin=2, nargout=1params.<field> references.Fail if function references params not in the hyperparameter table. Warn if table entries are unused.
[auto] — Validation result.m and .mat, re-validate (max 2 attempts)[user] escalate with error detailsAfter the experiment is created and Experiment Manager is open:
> Your experiment is ready in Experiment Manager! Here are some things you can do before running:
Suggested authoring actions:
> When you're ready, click Run in the Experiment Manager toolbar to start your trials.
writelines directly into project folder.'Plots', 'none' in trainingOptions (built-in training only). For general purpose and custom training, preserve the user's figure/plot code.params, not hardcoded.Project for project names and Experiment for experiment names (e.g., AntennaProject, AntennaExperiment).fullfile() with absolute path components.See references/REFERENCES.md for template classes, signature mappings, and common hyperparameters.
| Error | Fix |
|-------|-----|
| Validation fails | Fix function, rewrite .mat, re-validate (max 2 attempts) |
| Relative path found | Resolve to absolute against source script directory, rewrite |
| Project not open & can't create | Ask user for project location |
| >50 trials | Warn, suggest reducing values |
| Ambiguous experiment type | Ask user to clarify |
| File already exists | Append numeric suffix (_2, _3, ...) |
| Path cannot be resolved | Ask user for the full path |
Copyright 2026 The MathWorks, Inc.
Take matlab/matlab-create-experiment from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
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.