cheb2ord — Select the minimum Chebyshev Type II filter order.
cheb2ord(Wp, Ws, Rp, Rs) computes the minimum Chebyshev Type II 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] = cheb2ord(Wp, Ws, Rp, Rs)
[n, Wn] = cheb2ord(Wp, Ws, Rp, Rs, 's')Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
Wp | NumericArray | Yes | — | Passband edge or two-element passband edge vector. |
Ws | NumericArray | Yes | — | Stopband edge or two-element stopband edge vector. |
Rp | NumericScalar | Yes | — | Maximum passband ripple in dB. |
Rs | NumericScalar | Yes | — | Minimum stopband attenuation in dB. |
Wp | NumericArray | Yes | — | Analog passband edge or edge pair in rad/s. |
Ws | NumericArray | Yes | — | Analog stopband edge or edge pair in rad/s. |
s | StringScalar | Yes | — | Analog-design selector. |
Returns
| Name | Type | Description |
|---|---|---|
n | NumericScalar | Minimum Chebyshev Type II filter order. |
Wn | NumericArray | Natural cutoff frequency or frequency pair for Chebyshev Type II design. |
Returned values from cheb2ord depend on how many outputs the caller requests.
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:cheb2ord:ArgCount | The argument count is outside supported forms. | cheb2ord: expected cheb2ord(Wp, Ws, Rp, Rs [, 's']) |
RunMat:cheb2ord:InvalidFrequency | Passband or stopband edges are invalid. | cheb2ord: invalid passband or stopband frequency |
RunMat:cheb2ord:InvalidAttenuation | Ripple or attenuation values are invalid. | cheb2ord: Rp and Rs must be positive finite scalars with Rs > Rp |
RunMat:cheb2ord:InvalidOption | The optional selector is not supported. | cheb2ord: optional selector must be 's' |
RunMat:cheb2ord:TooManyOutputs | More than two output arguments are requested. | cheb2ord: too many output arguments |
RunMat:cheb2ord:Internal | Output tensor construction fails internally. | cheb2ord: internal error |
How cheb2ord works
[n, Wn] = cheb2ord(Wp, Ws, Rp, Rs)returns an integer ordernand Chebyshev Type II critical cutoffWn.- Scalar
WpandWsselect lowpass whenWp < Wsand highpass whenWp > 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.
Rsmust be greater thanRp, and both values are specified in decibels.
Examples
Lowpass order selection
[n, Wn] = cheb2ord(0.2, 0.3, 1, 40)Expected output:
n is the minimum order and Wn is the Type II critical frequency.Highpass order selection
[n, Wn] = cheb2ord(0.5, 0.3, 1, 40)Expected output:
Wn lies between the stopband and passband edges.Bandstop order selection
[n, Wn] = cheb2ord([0.1 0.6], [0.2 0.5], 3, 60)Expected output:
Wn is a two-element critical-frequency row vector.Analog lowpass order selection
[n, Wn] = cheb2ord(10, 20, 1, 40, 's')Expected output:
Wn is returned in rad/s for analog designs.Using cheb2ord with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how cheb2ord changes the result.
Run a small cheb2ord example, explain the result, then change one input and compare the output.
FAQ
What does Wn represent?⌄
Wn is the Chebyshev Type II critical frequency that satisfies the requested passband ripple and stopband attenuation. Scalar highpass designs return an edge between Ws and Wp; two-element designs return a sorted edge pair.
Does cheb2ord run on the GPU?⌄
No. It only computes small order/cutoff parameters on the host. Those parameters can feed Chebyshev filter design, and the resulting coefficients can later be used by GPU-capable filtering paths.
Related Math functions
Signal
blackman · butter · buttord · 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 · uint32
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
Optim
coneprog · fminbnd · fminunc · fsolve · fzero · integral · linprog · lsqcurvefit · lsqnonlin · optimset · quad · secondordercone
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how cheb2ord is executed, line by line, in Rust.
- View the source for cheb2ord 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.