padsequences — Pad or truncate numeric sequence cell arrays.

padsequences(sequences, paddingDim) pads or truncates numeric sequences stored in a cell array along the requested dimension.

Syntax

Y = padsequences(sequences, paddingDim)
Y = padsequences(sequences, paddingDim, Name, Value)

How padsequences works

  • sequences must be a cell array of numeric scalar/vector/tensor sequences.
  • paddingDim is a required positive integer dimension.
  • PaddingDirection accepts left, right, or both; the default is right.
  • Length accepts longest, shortest, or a positive integer.
  • PaddingValue accepts a finite numeric scalar and defaults to 0.
  • UniformOutput defaults to true and stacks padded sequences into a numeric tensor; false preserves the input cell shape.

GPU memory and residency

padsequences materializes host sequence tensors in this slice; provider-resident sequence padding remains future GPU work.

Examples

Right Pad Sequences

Y = padsequences({[1 2], 3}, 2, 'PaddingValue', -1)

Expected output:

A numeric tensor with right-padded row sequences.

Preserve Cell Shape

C = padsequences({[1 2 3], [4 5]}, 2, 'Length', 2, 'PaddingDirection', 'left', 'UniformOutput', false)

Expected output:

A cell array whose first sequence keeps the tail `[2 3]`.

Using padsequences with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how padsequences changes the result.

Run a small padsequences example, explain the result, then change one input and compare the output.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.