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

butter — Design Butterworth IIR filters.

butter(n, Wn) designs an order-n Butterworth filter. Digital designs use MATLAB's normalized convention where Wn = 1 is Nyquist. Scalar Wn produces a lowpass filter by default; a two-element Wn produces a bandpass filter by default. Add an ftype string for low, high, bandpass, or stop, and add 's' for analog transfer functions.

Syntax

b = butter(n, Wn)
b = butter(n, Wn, ftype)
b = butter(n, Wn, 's')
b = butter(n, Wn, ftype, 's')
[b, a] = butter(n, Wn)
[b, a] = butter(n, Wn, ftype)
All supported butter forms
b = butter(n, Wn)
b = butter(n, Wn, ftype)
b = butter(n, Wn, 's')
b = butter(n, Wn, ftype, 's')
[b, a] = butter(n, Wn)
[b, a] = butter(n, Wn, ftype)
[b, a] = butter(n, Wn, 's')
[b, a] = butter(n, Wn, ftype, 's')
[z, p, k] = butter(n, Wn)
[z, p, k] = butter(n, Wn, ftype)
[z, p, k] = butter(n, Wn, 's')
[z, p, k] = butter(n, Wn, ftype, 's')
[A, B, C, D] = butter(n, Wn)
[A, B, C, D] = butter(n, Wn, ftype)
[A, B, C, D] = butter(n, Wn, 's')
[A, B, C, D] = butter(n, Wn, ftype, 's')

Inputs

NameTypeRequiredDefaultDescription
nIntegerScalarYes—Filter order.
WnNumericArrayYes—Normalized digital cutoff frequency or analog cutoff frequency.
ftypeStringScalarNo"low" for scalar Wn, "bandpass" for two-element WnFilter type: low, high, bandpass, or stop.
WnNumericArrayYes—Analog cutoff frequency.
sStringScalarYes—Analog filter-design flag.
sStringScalarNo—Analog filter-design flag.

Returns

NameTypeDescription
bNumericArrayNumerator coefficient vector.
aNumericArrayDenominator coefficient vector.
zNumericArrayFilter zeros.
pNumericArrayFilter poles.
kNumericScalarFilter gain.
ANumericArrayState matrix.
BNumericArrayInput matrix.
CNumericArrayOutput matrix.
DNumericScalarFeedthrough term.

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

Errors

IdentifierWhenMessage
RunMat:butter:ArgCountThe argument count is outside butter's supported forms.butter: expected two to four input arguments
RunMat:butter:InvalidOrderFilter order is missing, non-finite, non-integer, less than one, or too large.butter: order must be a positive integer
RunMat:butter:InvalidFrequencyCutoff frequencies are malformed or outside the valid range.butter: invalid cutoff frequency
RunMat:butter:InvalidOptionFilter type or analog flag is malformed or unknown.butter: invalid option
RunMat:butter:TooManyOutputsMore than four outputs are requested.butter: too many output arguments
RunMat:butter:InternalFilter design or output materialization fails internally.butter: internal error

How butter works

  • b = butter(n, Wn) returns numerator coefficients as a row vector.
  • [b, a] = butter(...) returns numerator and denominator coefficient row vectors suitable for filter(b, a, x) in digital mode.
  • [z, p, k] = butter(...) returns zero-pole-gain form.
  • [A, B, C, D] = butter(...) returns a controllable-canonical state-space realization.
  • Digital cutoff frequencies must be finite, greater than 0, and less than 1. Analog cutoff frequencies must be finite and greater than 0.
  • Bandpass and bandstop designs require a strictly increasing two-element Wn vector.
  • MATLAB-compatible calls use double for n and Wn, limit n to 500, and return double outputs. RunMat mode additionally admits independently gated integer, logical, single, resident, option-alias, and larger-order forms.
  • Typed-integer n is parsed exactly as a structural order. Typed-integer Wn is explicitly converted at the double filter-design boundary, and every supported output remains host double.
  • The documented cascaded-transfer-function ("ctf") forms introduced in MATLAB R2024b are not yet implemented.

Examples

Low-pass filtering a noisy signal

fs = 1000;
t = (0:999) / fs;
x = sin(2*pi*25*t) + 0.2*sin(2*pi*200*t);
[b, a] = butter(4, 80/(fs/2), 'low');
y = filter(b, a, x);

Expected output:

y contains the low-pass filtered signal.

High-pass filter coefficients

[b, a] = butter(2, 0.25, 'high')

Expected output:

b and a are row-vector IIR coefficients.

Band-pass filter coefficients

[b, a] = butter(3, [0.2 0.4], 'bandpass')

Expected output:

b and a each contain 7 coefficients.

Analog low-pass prototype

[b, a] = butter(1, 2, 's')

Expected output:

b = [0 2]
a = [1 2]

Using butter with coding agents

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

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

FAQ

What does Wn mean for digital filters?⌄

RunMat follows MATLAB's normalized digital convention: Wn = 1 is the Nyquist frequency, so a 600 Hz low-pass filter at a 4800 Hz sample rate uses butter(n, 600/(4800/2)).

Can I use the result directly with filter?⌄

Yes. Digital [b, a] outputs are ordinary row vectors and can be passed directly to filter(b, a, x).

Does butter execute on the GPU?⌄

The documented API lists code generation but no interactive gpuArray overload. In MATLAB-compatible mode RunMat rejects resident arguments before gather; RunMat mode can gather them and generate host double coefficients. GPU acceleration applies when those coefficients are later used by filter with a real gpuArray signal and a provider that implements iir_filter.

Related Math functions

Signal

blackman · 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

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 butter is executed, line by line, in Rust.

  • View the source for butter 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 butter works
  • Examples
  • Low-pass filtering a noisy signal
  • High-pass filter coefficients
  • Band-pass filter coefficients
  • Analog low-pass prototype
  • Using butter 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