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

filtfilt — Apply zero-phase forward-backward digital filtering.

filtfilt(b, a, x) filters a vector forward and backward to remove phase delay. Coefficients follow the same digital-filter convention as filter: b is the numerator, a is the denominator, and a(1) is normalized internally.

Syntax

y = filtfilt(b, a, x)

Inputs

NameTypeRequiredDefaultDescription
bAnyYes—Numerator coefficient vector.
aAnyYes—Denominator coefficient vector.
xAnyYes—Input signal vector.

Returns

NameTypeDescription
yNumericArrayZero-phase filtered signal.

Errors

IdentifierWhenMessage
RunMat:filtfilt:ArgCountThe argument count is not exactly three.filtfilt: expected filtfilt(b, a, x)
RunMat:filtfilt:InvalidCoefficientsCoefficient inputs are empty, non-vector, or have a zero leading denominator.filtfilt: invalid coefficient input
RunMat:filtfilt:InvalidSignalThe signal is not a numeric/logical vector or is too short for edge reflection.filtfilt: invalid signal input
RunMat:filtfilt:InternalInternal state solving, filtering, or tensor construction fails.filtfilt: internal error

How filtfilt works

  • The v1 implementation supports vector signals and preserves row or column orientation.
  • The three-argument path uses constant steady-state initialization and linear endpoint continuation with 3 * (max(numel(a), numel(b)) - 1) transient samples, matching the compatibility target's defaults for the implemented coefficient-vector/vector-signal form.
  • Input length must be greater than the reflection length unless the filter has zero state.
  • Real floating gpuArray inputs use provider-backed filter passes when available; complex inputs fall back to the host reference path. Typed-integer and logical inputs are independently gated RunMat-only extensions. Calls containing a single input retain single output; integer/logical-only calls produce double output.

Does RunMat run filtfilt on the GPU?

Real gpuArray signal inputs are eligible for provider-backed forward and reverse filter passes through the existing iir_filter hook.

If provider execution is unavailable or inputs are complex, RunMat gathers to the host and evaluates the MATLAB-compatible reference path.

Examples

Compare causal filtering with zero-phase filtering

b = ones(1, 3) / 3;
a = 1;
x = 1:20;
y_causal = filter(b, a, x);
y_zero = filtfilt(b, a, x);
fprintf('%.4f %.4f\n', y_causal(8), y_zero(8));

Expected output:

7.0000 8.0000

Filter with FIR coefficients from fir1

b = fir1(10, 0.25, 'low');
x = 1:40;
y = filtfilt(b, 1, x);

Run zero-phase filtering on a gpuArray

g = gpuArray(1:40);
b = ones(1, 3) / 3;
y_gpu = filtfilt(b, 1, g);
y = gather(y_gpu);

Using filtfilt with coding agents

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

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

FAQ

How is filtfilt different from filter?⌄

filter is causal and introduces phase delay. filtfilt applies the filter forward and backward, cancelling that phase delay while doubling the magnitude response order.

Does filtfilt support matrices?⌄

This initial implementation supports vector inputs. Matrix and explicit-dimension support should be added as a separate compatibility expansion.

Can I use Butterworth or FIR coefficients?⌄

Yes. Coefficients from butter, fir1, or hand-written digital filters can be used as long as a(1) is non-zero.

Related Math functions

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · 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 filtfilt is executed, line by line, in Rust.

  • View the source for filtfilt 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 filtfilt works
  • Does RunMat run filtfilt on the GPU?
  • Examples
  • Compare causal filtering with zero-phase filtering
  • Filter with FIR coefficients from fir1
  • Run zero-phase filtering on a gpuArray
  • Using filtfilt 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