RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • blackman
    • butter
    • buttord
    • cheb2ord
    • conv
    • conv2
    • deconv
    • downsample
    • envelope
    • filter
    • filtfilt
    • fir1
    • freqz
    • gauspuls
    • hamming
    • hann
    • hilbert
    • periodogram
    • pulstran
    • pwelch
    • rectpuls
    • resample
    • sawtooth
    • sinc
    • spectrogram
    • square
    • tripuls
    • unwrap
    • upsample
    • zplane

envelope — Compute upper and lower signal envelopes.

envelope(x) returns upper and lower envelopes for a finite real signal vector or for each column of a finite real matrix. The default analytic mode removes each channel mean, computes the magnitude of the analytic signal, and adds the mean back to the upper and lower bounds.

Syntax

yupper = envelope(x)
[yupper, ylower] = envelope(x)
yupper = envelope(x, n, method)
[yupper, ylower] = envelope(x, n, method)

Inputs

NameTypeRequiredDefaultDescription
xNumericArrayYes—Finite real-valued signal vector or matrix, processed column-wise.
nNumericScalarYes—Filter/window length for analytic or RMS mode, or peak separation for peak mode.
methodStringScalarNo"analytic"Envelope method: `analytic`, `rms`, or `peak`.

Returns

NameTypeDescription
yupperNumericArrayUpper signal envelope.
ylowerNumericArrayLower signal envelope.

Returned values from envelope depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:envelope:ArgCountThe argument count is outside supported forms.envelope: expected envelope(x), envelope(x, n), or envelope(x, n, method)
RunMat:envelope:InvalidSignalInput is not a finite real numeric vector or matrix.envelope: x must be a finite real numeric vector or matrix
RunMat:envelope:InvalidLengthFilter/window length or peak separation is not a positive integer.envelope: n must be a positive integer scalar
RunMat:envelope:InvalidMethodMethod is not analytic, rms, or peak.envelope: method must be 'analytic', 'rms', or 'peak'
RunMat:envelope:InternalEnvelope computation or output tensor assembly fails internally.envelope: internal error
RunMat:envelope:TooManyOutputsMore than two output arguments are requested.envelope: expected at most two output arguments

How envelope works

  • yupper = envelope(x) returns the upper envelope.
  • [yupper, ylower] = envelope(x) returns both bounds.
  • envelope(x, n) uses analytic mode and computes the analytic signal with a Kaiser-windowed Hilbert FIR filter of length n.
  • envelope(x, n, 'analytic') explicitly selects the same Hilbert FIR-filter path.
  • envelope(x, wl, 'rms') computes a centered sliding RMS envelope over a window of wl samples.
  • envelope(x, np, 'peak') detects local maxima/minima separated by at least np samples and interpolates them with a spline curve.
  • Statement form with no outputs plots the signal with the upper and lower envelopes.
  • MATLAB-compatible mode accepts single- and double-precision signal data and controls. Typed-integer signal data or length controls are explicit RunMat extensions; integer data crosses into the floating envelope computation only after exact storage is read.
  • The public source does not state the output class for single-precision host input, so that compatibility detail remains evidence-open. RunMat preserves single-precision output for single-precision input consistently across host and resident execution.

Examples

Analytic envelope of an amplitude-modulated tone

t = (0:127) / 128;
x = (1.25 + 0.5*sin(2*pi*t)) .* sin(2*pi*8*t);
[up, lo] = envelope(x);

Centered moving RMS envelope

x = [0 3 4 0];
[up, lo] = envelope(x, 3, 'rms');

Peak envelope

x = [0 2 0 -1 0 3 0];
[up, lo] = envelope(x, 2, 'peak');

Column-wise matrix envelopes

x = [sin(0:0.1:10)' cos(0:0.1:10)'];
[up, lo] = envelope(x);

Using envelope with coding agents

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

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

FAQ

What is the default envelope method?⌄

The default is analytic-envelope mode using the magnitude of the analytic signal.

How are matrix inputs handled?⌄

envelope processes each matrix column independently and returns outputs with the same shape as the input.

Does envelope plot when no outputs are requested?⌄

Yes. Statement form renders the signal, upper envelope, and lower envelope using the line-plot pipeline.

Related Math functions

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

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 · typecast · uint16 · uint32 · uint8

Trigonometry

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

Reduction

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

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

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

Optim

coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimoptions · optimset · quad · secondordercone

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Symbolic

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

Fft

fft · fft2 · fftn · fftshift · ifft · ifft2 · ifftn · ifftshift

Interpolation

griddedInterpolant · interp1 · interp1q · interp2 · pchip · ppval · spline

Discrete

lcm · primes

Ode

ode15s · ode23 · ode45

Poly

polyder · polyfit · polyint · polyval · roots

Open-source implementation

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

  • View the source for envelope in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How envelope works
  • Examples
  • Analytic envelope of an amplitude-modulated tone
  • Centered moving RMS envelope
  • Peak envelope
  • Column-wise matrix envelopes
  • Using envelope with coding agents
  • FAQ
  • Related Math functions
  • Signal
  • Elementwise
  • Trigonometry
  • Reduction
  • Structure
  • Rounding
  • Factor
  • Solve
  • Optim
  • Ops
  • Symbolic
  • Fft
  • Interpolation
  • Discrete
  • Ode
  • Poly
  • Open-source implementation
  • About RunMat