movmax — Compute moving maximum values in MATLAB and RunMat.

movmax(A,k) returns the maximum value in each sliding window.

Syntax

M = movmax(A, k)
M = movmax(A, k, dim)
M = movmax(A, k, nanflag)
M = movmax(A, k, Name, Value)
M = movmax(A, k, nanflag, Name, Value)
M = movmax(A, k, dim, Name, Value)

Inputs

NameTypeRequiredDefaultDescription
AAnyYesInput numeric, logical, or gpuArray data.
kNumericArrayYesWindow length or two-element [kb kf] backward/forward window.
dimNumericArrayNoDimension along which to move the window.
nanflagStringScalarNo"includenan"NaN handling mode: "includenan" or "omitnan".
NameValueAnyVariadicName-value options, including "Endpoints".

Returns

NameTypeDescription
MNumericArrayMoving-window reduction result.

Errors

IdentifierWhenMessage
RunMat:movmax:InvalidArgumentWindow length, dimension, nanflag, or name-value options are invalid.moving window: invalid argument
RunMat:movmax:InvalidInputInput values cannot be converted to a supported moving-window domain.moving window: invalid input
RunMat:movmax:InternalMoving-window execution fails due to allocation, provider, or shape operations.moving window: internal failure

How movmax works

  • k may be a positive scalar window length or a two-element [kb kf] backward/forward window.
  • Pass an explicit dim to move along a chosen dimension.
  • 'omitnan'/'omitmissing' is the default for movmax; 'includenan' propagates NaN values inside each window.
  • 'Endpoints' supports 'shrink' (default), 'discard', 'fill', and numeric scalar fill values.
  • 'fill' uses negative infinity for movmax, matching MATLAB endpoint fill behavior.
  • 'SamplePoints', sp uses a strictly increasing numeric point vector for irregular moving windows. With sample points, RunMat currently supports shrink endpoints.
  • Complex inputs are ordered by magnitude with phase as the tie breaker.
  • This implementation covers numeric, logical, complex, and gpuArray inputs; table/timetable DataVariables forms are tracked separately.

Example

Discard incomplete endpoint windows

M = movmax([1 9 3 4], 3, 'Endpoints', 'discard')

Expected output:

M = [9 9]

Using movmax with coding agents

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

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

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · min · mink · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Elementwise

abs · angle · bsxfun · complex · conj · double · erf · erfcinv · exp · expm1 · factorial · flintmax · gamma · gammaln · heaviside · hypot · idivide · imag · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · swapbytes · times · uint32

Trigonometry

acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · decomposition · eig · eigs · lu · qr · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref · vecnorm

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Fft

fft · fft2 · fftshift · ifft · ifft2 · ifftshift

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how movmax is executed, line by line, in Rust.

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.