Skip to content

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

matlab-prepare-signal-data

Verified

Use this skill when conditioning, loading, preparing, or labeling signal data for analysis or ML training. Covers: cleaning a single signal (fill gaps, remove drift, deoutlier, denoise, resample/align a time base) BEFORE analysis; building a `signalDatastore` pipeline; creating a `labeledSignalSet` for Signal Labeler; deriving labels (filename, folder, in-file, ROI, time-frequency ROI); stratified train/val/test splits; framing long signals; parallel processing; and shaping datastore output for `trainnet`. Triggers include "clean up this signal", "remove drift / detrend", "fill gaps", "remove spikes / outliers", "denoise", "resample to a uniform rate", "align channels", "labels from filenames", "stratified split", "prepare for Signal Labeler", and function names like `fillgaps`, `fillmissing`, `detrend`, `filloutliers`, `smoothdata`, `resample`, `synchronize`, `signalDatastore`, `labeledSignalSet`, `filenames2labels`, `folders2labels`, `splitlabels`, `framesig`, `framelbl`, `createDatastores`.

FileKindSize
SKILL.mdskill md9.5 KB
manifest.yamlconfig650 B
references/fn-countlabels.mdmarkdown2.1 KB
references/fn-detrend.mdmarkdown4.6 KB
references/fn-filenames2labels.mdmarkdown4.8 KB
references/fn-fillgaps.mdmarkdown3.3 KB
references/fn-fillmissing.mdmarkdown4.2 KB
references/fn-filloutliers.mdmarkdown5.0 KB
references/fn-folders2labels.mdmarkdown3.4 KB
references/fn-framelbl.mdmarkdown7.1 KB
references/fn-framesig.mdmarkdown4.1 KB
references/fn-hampel.mdmarkdown3.3 KB
references/fn-labeledsignalset.mdmarkdown9.1 KB
references/fn-labelspectrogramoptions.mdmarkdown4.6 KB
references/fn-medfilt1.mdmarkdown3.3 KB
references/fn-partition.mdmarkdown4.6 KB
references/fn-resample.mdmarkdown4.6 KB
references/fn-retime.mdmarkdown4.7 KB
references/fn-sgolayfilt.mdmarkdown3.5 KB
references/fn-signaldatastore.mdmarkdown11.9 KB
references/fn-signallabeldefinition.mdmarkdown5.9 KB
references/fn-signalmask-getmask.mdmarkdown8.6 KB
references/fn-smoothdata.mdmarkdown4.8 KB
references/fn-splitlabels.mdmarkdown5.3 KB
references/fn-subset.mdmarkdown3.9 KB
references/fn-synchronize.mdmarkdown4.7 KB
references/fn-wdenoise.mdmarkdown5.2 KB
references/wf-align-channels.mdmarkdown6.6 KB
references/wf-custom-readfcn.mdmarkdown5.0 KB
references/wf-denoise.mdmarkdown2.6 KB
references/wf-detrend-smooth-deoutlier.mdmarkdown6.6 KB
references/wf-envelope.mdmarkdown5.3 KB
references/wf-frame-and-label.mdmarkdown4.7 KB
references/wf-handoff-to-dl.mdmarkdown9.1 KB
references/wf-label-and-export.mdmarkdown8.7 KB
references/wf-load-and-split.mdmarkdown4.6 KB
references/wf-parallel-process.mdmarkdown4.8 KB
references/wf-repair-missing.mdmarkdown6.7 KB
references/wf-uniform-rate.mdmarkdown4.2 KB

references/fn-synchronize.md

View on GitHub
# Function: `synchronize`

> Used in: wf-align-channels.md
> Toolbox: MATLAB (base) — timetable method

The one-shot merge primitive for bringing several timetables onto a shared
time base.
It collects the variables from all input timetables, builds a common time
vector, adjusts each variable onto it, and returns a single timetable.

Reach for `synchronize` whenever you have two or more timetables at different
rates or offsets that need to become one aligned table.
Do not hand-orchestrate `retime` per channel and then concatenate — that is
the multi-step path `synchronize` collapses into one call.

## Signature

```matlab
TT = synchronize(TT1, TT2)                                  % union of times, no interpolation
TT = synchronize(TT1, TT2, newTimeBasis, method)            % common basis + adjust rule
TT = synchronize(TT1, TT2, newTimeStep, method)             % 'hourly', 'daily', ...
TT = synchronize(TT1, TT2, 'regular', method, 'SampleRate', Fs)
TT = synchronize(TT1, TT2, 'regular', method, 'TimeStep', dt)
TT = synchronize(TT1, TT2, newTimes, method)                % explicit target time vector
TT = synchronize(TT1, ..., TTN, ___)                        % N timetables at once
```

`newTimeBasis` picks where the common row times come from:

| `newTimeBasis` | Common time vector is | Use when |
|---|---|---|
| `'union'` (default) | every distinct time across all inputs | you want to keep all samples and fill the rest |
| `'intersection'` | only times present in every input | you want rows that already line up, no interpolation |
| `'commonrange'` | inputs' overlapping span, at union times inside it | you want the overlap only, dropping non-overlapping tails |
| `'first'` | `TT1`'s row times | you want everything on the first table's grid |
| `'last'` | `TTN`'s row times | you want everything on the last table's grid |
| `'regular'` | a uniform grid (needs `SampleRate` or `TimeStep`) | you want a clean uniform output rate |

`method` is the adjustment rule applied to each variable at the new times.
Same vocabulary as `retime` (see fn-retime.md): `'fillwithmissing'` (default
when no method given), `'linear'`, `'spline'`, `'pchip'`, `'makima'`,
`'previous'`, `'next'`, `'nearest'`, plus aggregation rules (`'mean'`,
`'sum'`, ...) and `'fillwithconstant'`.

## Name-value pairs

| NV-pair | Default | Purpose |
|---|---|---|
| `EndValues` | `'extrap'` | Extrapolation rule for interpolation methods. `'extrap'` extends the trend past the data (can invent values); set to a scalar to clip instead. |
| `Constant` | — | Fill value when `method` is `'fillwithconstant'`. |
| `IncludedEdge` | `'left'` | Which bin edge is included when aggregating. |

## The default is fill-with-missing, not interpolation

`synchronize(TT1, TT2)` with **no method** uses the union of times and
inserts `NaN` (or `NaT`/`<undefined>`) wherever a variable has no sample.
It does not interpolate.

```matlab
TT = synchronize(A, B);          % union grid, NaNs at non-overlapping times
```

This is the honest default — it never fabricates values.
It also means align typically **creates missing data** at times where one
channel has no sample, so it precedes a fill step.
See wf-repair-missing.md for the fill that follows.

To adjust onto the grid instead of NaN-filling, pass a method:

```matlab
TT = synchronize(A, B, 'first', 'linear');   % B interpolated onto A's times
```

## Gotchas

- **No method = NaN fill.** If you expected interpolated values and got NaNs, you omitted the `method` argument. The two-argument form never interpolates.
- **`'linear'` extrapolates by default.** With `EndValues='extrap'` (the default), a channel that starts later than the common grid gets values extended backward past its first real sample. Pass `EndValues=NaN` (or a scalar) to refuse extrapolation, then fill deliberately.
- **`'union'` keeps every time from every input** — the output can be much longer than any single input and mostly NaN before filling. Use `'first'`/`'last'`/`'regular'` when you want a controlled grid size.
- **Row times must be sorted and unique per input.** Duplicate times need a resolution rule; `synchronize` errors otherwise. Deduplicate with `retime`/`unique` first.
- **All inputs must use the same time type** (all `duration`, or all `datetime`). Mixed `duration`/`datetime` inputs error.

## See also

- fn-retime.md — the single-timetable sibling. `synchronize` is essentially `retime` applied across several tables at once, plus the merge.
- fn-resample.md — for antialiased rate conversion of a signal (not a timetable merge).
- wf-align-channels.md — the end-to-end alignment workflow.
- wf-repair-missing.md — the fill step that follows a NaN-producing align.

----

Copyright 2026 The MathWorks, Inc.

----
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall