agentsclimarketplace

Matlab prepare signal data

Skill matlab/matlab-agentic-toolkit/skills-catalog/signal-processing/matlab-prepare-signal-data

Use this skill when building a `signalDatastore` pipeline for ML training: loading signals from .mat / .csv / .dat folders (and `.wav` when Audio Toolbox is unavailable), deriving labels (filename, folder, in-file column, ROI), splitting into train/val/test, framing long signals for per-frame supervision, parallel processing across a parpool, or shaping a datastore output for `trainnet`. Triggers include the function names `signalDatastore`, `filenames2labels`, `folders2labels`, `splitlabels`, `countlabels`, `framesig`, `framelbl`, `signalMask`, `catmask`, and workflow phrases like "labels from filenames", "stratified split", "ReadFcn for signalDatastore", "load mat/csv/wav for training".From its SKILL.md

Install
npx -y skills add matlab/matlab-agentic-toolkit --skill matlab-prepare-signal-data

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its file declares

Copied from the file, not written here

The file declares its own license as MathWorks BSD-3-Clause. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

6.9 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it

Prepare Signal Data for ML Training

Look in Signal Processing Toolbox first. The labeling, splitting, framing, and partitioning helpers for signalDatastore live in Signal Processing Toolbox — not in Stats & ML Toolbox or generic-MATLAB string utilities.

When to Use

Loading or preparing signal / time-series data for ML training in MATLAB. Reach for this skill especially when you want:

  • labels derived from filenames or folder names
  • stratified train/val/test splits over a datastore
  • per-frame labels from ROI tables on long signals
  • parallel processing of signals across a parpool
  • a datastore shaped to feed trainnet

When NOT to Use

  • Raw .wav audio classification with Audio Toolbox available. audioDatastore is the canonical path. If Audio Toolbox is not available, this skill's custom-ReadFcn workflow handles .wav via base-MATLAB audioread — see references/wf-custom-readfcn.md.

Best practices

  • Deliverable is a runnable .m script the user can save and re-run — not workspace state. The output of this skill is a reusable data-prep pipeline the user can version and hand off.

§ 0 Common reflexes

If your first instinct is one of these, the canonical replacement is one row away.

ReflexCanonicalDetail
Custom ReadFcn for a .csvsignalDatastore default reader + SignalVariableNamesreferences/fn-signaldatastore.md
cvpartition for a datastore splitsplitlabels + subset(ds, idx{k}) (cell-array indexing)references/fn-splitlabels.md
regexp / extractBefore / fileparts to derive labels from filenamesfilenames2labels(sds, Extract=...)references/fn-filenames2labels.md
regexp / hand-rolled fileparts(fileparts(...)) for labels from subfoldersfolders2labels(sds.Files) — pass the datastore's file listreferences/fn-folders2labels.md
parfor i = 1:numel(ds.Files) constructing a fresh datastore per filepartition(ds, N, k) per workerreferences/fn-partition.md, references/wf-parallel-process.md
Manual framing loop with (i-1)*hopSize+1framesig(x, fl, OverlapLength=...)references/fn-framesig.md, references/wf-frame-and-label.md
Manual ROI-to-frame label vote with containers.Mapframelbl(rois, ConsolidationMethod=..., PriorityList=...)references/fn-framelbl.md, references/wf-frame-and-label.md
for loop calling load(file) to extract labels from in-file variablessignalDatastore(folder, SignalVariableNames=["x","label"])the loop goes away; both variables come back per read(sds) as a cell rowreferences/fn-signaldatastore.md

§ 1 Workflows

Each workflow file is the entry point; it links the function-detail files you'll need at each step.

WorkflowUse whenReference (entry → chain)
Load + label + splitBuilding a datastore from a folder of files for training.wf-load-and-split.md → fn-signaldatastore, fn-filenames2labels / fn-folders2labels, fn-countlabels, fn-splitlabels, fn-subset
Frame long signals + per-frame labelsSignals are long; supervision is per-window.wf-frame-and-label.md → fn-framesig, fn-framelbl, fn-signalmask-getmask
Parallel processing across a parpoolComputing per-signal results across workers.wf-parallel-process.md → fn-partition
Custom ReadFcn (only when needed)File format isn't .mat / .csv, or has a metadata prelude.wf-custom-readfcn.md → fn-signaldatastore
Hand-off to trainnetDatastore is ready; next step is shaping for trainnet / combine / arrayDatastore (routes to minibatchqueue / dlarray for custom batching or GPU prefetching).wf-handoff-to-dl.md

§ 2 Functions

FunctionUsed forReference
signalDatastoreDatastore constructor (.mat / .csv / custom).references/fn-signaldatastore.md
filenames2labelsCategorical labels from filename pattern.references/fn-filenames2labels.md
folders2labelsCategorical labels from containing-folder name.references/fn-folders2labels.md
splitlabelsStratified train/val/test index sets.references/fn-splitlabels.md
countlabelsPer-class file count for balance checks.references/fn-countlabels.md
subsetSlice a datastore by index (single-process).references/fn-subset.md
partitionSlice a datastore across parpool workers.references/fn-partition.md
framesigFrame a signal into windows with overlap.references/fn-framesig.md
framelblCollapse ROI rows into per-frame labels.references/fn-framelbl.md
signalMask / catmask / binmaskPer-sample masks from ROI tables.references/fn-signalmask-getmask.md

§ 3 Highest-frequency canonical patterns (inline)

3.1 CSV is first-class — no custom ReadFcn for tabular CSV

sds = signalDatastore(folder, ...
    FileExtensions=".csv", ...
    SignalVariableNames=["ch1","ch2"]);

Don't wrap readtable(..., 'SelectedVariableNames', ...) in a custom ReadFcn. The default reader does this directly. Full table: references/fn-signaldatastore.md.

3.2 Filename labels — position-independent extraction

labels = filenames2labels(sds, Extract = "G" + digitsPattern);

Don't reach for extractBefore("_") / regexp — silent wrong labels when filename format varies. More patterns: references/fn-filenames2labels.md.

3.3 Stratified split — splitlabels + subset

splitIndices = splitlabels(labels, [0.7 0.15 0.15]);
sdsTrain = subset(sds, splitIndices{1});
sdsVal   = subset(sds, splitIndices{2});
sdsTest  = subset(sds, splitIndices{3});
% splitIndices{4} exists but is empty here (ratios sum to 1).

splitlabels returns an (N+1)-element cell array of index vectors. When sum(ratios) == 1 (as above) the last cell is empty; when sum(ratios) < 1 the last cell holds the leftover indices.

Don't use cvpartition for datastore-backed splits — requires materializing labels first and doesn't compose with subset. Full contract: references/fn-splitlabels.md.


Copyright 2026 The MathWorks, Inc.


What ships with it: 38 files

196.0 KB alongside SKILL.md

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.