Skip to content

Slice a signal into windows

What it does

Extracts fixed-length windows from a sampled signal, with overlap specified in samples.

When to use it

Use it to prepare windows for spectral analysis or other operations that process successive parts of a signal independently.

Canonical ID: tools.slicesignal

Inputs

Name Meaning Type Unit Requirements
signal Nonempty sampled signal. real vector a.u. minimum length: 1; NaN allowed; Inf allowed
window_length Number of samples per window. integer scalar sample minimum: 1; no NaN; finite
overlap Number of samples shared by consecutive windows. integer scalar sample minimum: 0; no NaN; finite

Parameters

Name Meaning Type Unit Default Requirements
sampling_frequency Optional sampling frequency, required to calculate time centers. real scalar Hz not applicable greater than: 0
use_last Include an uncovered final window with NaN padding. boolean dimensionless no not specified

Outputs

Name Meaning Type Unit
window_samples Window samples in chronological window order, exposed as columns in MATLAB or rows in Python. real vector a.u.
time_centers Nominal time center of each window, in seconds from the first sample. real vector s

How it works

The first window begins at the first sample. Later windows advance by the window length minus the overlap. By default only complete windows are returned. Enable the last-window option to include an uncovered tail with right-side NaN padding, or to pad a nonempty signal shorter than one window.

Interpretation and limitations

MATLAB stores windows as columns and Python stores them as rows. The sample contents and window order are the same. If you provide the sampling frequency, you can obtain the time centers. These refer to the nominal window grid, including any padding, and use the first input sample as time zero. Existing missing samples are preserved.

Implementations and technical resources

Python source | MATLAB source

Normative JSON | Validation cases