RunMat
GitHub

buttord — Select the minimum Butterworth filter order.

buttord(Wp, Ws, Rp, Rs) computes the minimum Butterworth filter order and natural cutoff Wn that satisfy passband ripple Rp and stopband attenuation Rs. Digital frequencies use MATLAB's normalized convention where 1 is Nyquist; add 's' for analog rad/s designs.

Syntax

[n, Wn] = buttord(Wp, Ws, Rp, Rs)
[n, Wn] = buttord(Wp, Ws, Rp, Rs, 's')

Inputs

NameTypeRequiredDefaultDescription
WpNumericArrayYesPassband edge or two-element passband edge vector.
WsNumericArrayYesStopband edge or two-element stopband edge vector.
RpNumericScalarYesMaximum passband ripple in dB.
RsNumericScalarYesMinimum stopband attenuation in dB.
WpNumericArrayYesAnalog passband edge or edge pair in rad/s.
WsNumericArrayYesAnalog stopband edge or edge pair in rad/s.
sStringScalarYesAnalog-design selector.

Returns

NameTypeDescription
nNumericScalarMinimum Butterworth filter order.
WnNumericArrayNatural cutoff frequency or frequency pair for butter.

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

Errors

IdentifierWhenMessage
RunMat:buttord:ArgCountThe argument count is outside supported forms.buttord: expected buttord(Wp, Ws, Rp, Rs [, 's'])
RunMat:buttord:InvalidFrequencyPassband or stopband edges are invalid.buttord: invalid passband or stopband frequency
RunMat:buttord:InvalidAttenuationRipple or attenuation values are invalid.buttord: Rp and Rs must be positive finite scalars with Rs > Rp

How buttord works

  • [n, Wn] = buttord(Wp, Ws, Rp, Rs) returns an integer order n and cutoff Wn for use with butter(n, Wn).
  • Scalar Wp and Ws select lowpass when Wp < Ws and highpass when Wp > Ws.
  • Two-element edge vectors select bandpass when the stopband encloses the passband and bandstop when the passband encloses the stopband.
  • Digital inputs must be finite, positive, and less than 1. Analog inputs must be finite and positive.
  • Rs must be greater than Rp, and both values are specified in decibels.

Examples

Lowpass order selection

[n, Wn] = buttord(0.2, 0.3, 1, 40);
[b, a] = butter(n, Wn);

Highpass order selection

[n, Wn] = buttord(0.5, 0.3, 1, 40);
[b, a] = butter(n, Wn, 'high');

Bandpass order selection

[n, Wn] = buttord([0.3 0.5], [0.2 0.6], 1, 30);
[b, a] = butter(n, Wn, 'bandpass');

Analog lowpass order selection

[n, Wn] = buttord(10, 20, 1, 40, 's');
[b, a] = butter(n, Wn, 's');

Using buttord with coding agents

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

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

FAQ

What should I pass to butter after buttord?

Pass the returned n and Wn directly. For scalar highpass designs, also pass 'high'; for two-element bandpass or bandstop designs, pass 'bandpass' or 'stop' to match the edge layout.

Does buttord run on the GPU?

No. It only computes small order/cutoff parameters on the host. Those parameters can feed butter, and the resulting coefficients can later be used by GPU-capable filtering paths.

Elementwise

abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times

Trigonometry

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

Reduction

all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · eig · lu · qr · svd

Solve

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

Symbolic

digits · int · limit · sym · syms · vpa

Fft

fft · fft2 · fftshift · ifft · ifft2 · ifftshift

Interpolation

interp1 · interp2 · pchip · ppval · spline

Ode

ode15s · ode23 · ode45

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how buttord 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.