en fr

Library - filter

filter is a library which adds to LME functions for designing analog (continuous-time) and digital (discrete-time) linear filters.

The following statement makes available functions defined in filter:

use filter


This library provides three kinds of functions:

• besselap, buttap, cheb1ap, cheb2ap, and ellipap, which compute the zeros, poles and gain of the prototype of analog low-pass filter with a cutoff frequency of 1 rad/s. They correspond respectively to Bessel, Butterworth, Chebyshev type 1, Chebyshev type 2, and elliptic filters.
• besself, butter, cheby1, cheby2, and ellip, which provide a higher-level interface to design filters of these different types. In addition to the filter parameters (degree, bandpass and bandstop ripples), one can specify the kind of filter (lowpass, highpass, bandpass or bandstop) and the cutoff frequency or frequencies. The result can be an analog or a digital filter, given as a rational transfer function or as zeros, poles and gain.
• lp2lp, lp2hp, lp2bp, and lp2bs, which convert analog lowpass filters respectively to lowpass, highpass, bandpass, and bandstop with specified cutoff frequency or frequencies.

Transfer functions are expressed as the coefficient vectors of their numerator num and denominator den in decreasing powers of s (Laplace transform for analog filters) or z (z transform for digital filters); or as the zeros z, poles p, and gain k.

Functions

besselap

Bessel analog filter prototype.

Syntax

use filter
(z, p, k) = besselap(n)


Description

besselap(n) calculates the zeros, the poles, and the gain of a Bessel analog filter of degree n with a cutoff angular frequency of 1 rad/s.

besself

Bessel filter.

Syntax

use filter
(z, p, k) = besself(n, w0)
(num, den) = besself(n, w0)
(...) = besself(n, [wl, wh])
(...) = besself(n, w0, 'high')
(...) = besself(n, [wl, wh], 'stop')
(...) = besself(..., 's')


Description

besself calculates a Bessel filter. The result is given as zeros, poles and gain if there are three output arguments, or as numerator and denominator coefficient vectors if there are two output arguments.

besself(n,w0), where w0 is a scalar, gives a digital lowpass filter of order n with a cutoff frequency of w0 relatively to half the sampling frequency.

besself(n,[wl,wh]), where the second input argument is a vector of two numbers, gives a digital bandpass filter of order 2*n with passband between wl and wh relatively to half the sampling frequency.

besself(n,w0,'high') gives a digital highpass filter of order n with a cutoff frequency of w0 relatively to half the sampling frequency.

besself(n,[wl,wh],'stop'), where the second input argument is a vector of two numbers, gives a digital bandstop filter of order 2*n with stopband between wl and wh relatively to half the sampling frequency.

With an additional input argument which is the string 's', besself gives an analog Bessel filter. Frequencies are given in rad/s.

bilinear

Analog-to-digital conversion with bilinear transformation.

Syntax

use filter
(zd, pd, kd) = bilinear(zc, pc, kc, fs)
(numd, dend) = bilinear(numc, denc, fs)


Description

bilinear(zc,pc,kc,fs) converts the analog (continuous-time) transfer function given by its zeros zc, poles pc, and gain kc to a digital (discrete-time) transfer function given by its zeros, poles, and gain in the domain of the forward-shift operator q. The sampling frequency is fs. Conversion is performed with the bilinear transormation zd=(1+zc/(2*fs))/(1-zc/(2*fs)). If the analog transfer function has less zeros than poles, additional digital zeros are added at -1 to avoid a delay.

With three input arguments, bilinear(numc,denc,fs) uses the coefficients of the numerators and denominators instead of their zeros, poles and gain.

buttap

Butterworth analog filter prototype.

Syntax

use filter
(z, p, k) = buttap(n)


Description

buttap(n) calculates the zeros, the poles, and the gain of a Butterworth analog filter of degree n with a cutoff angular frequency of 1 rad/s.

butter

Butterworth filter.

Syntax

use filter
(z, p, k) = butter(n, w0)
(num, den) = butter(n, w0)
(...) = butter(n, [wl, wh])
(...) = butter(n, w0, 'high')
(...) = butter(n, [wl, wh], 'stop')
(...) = butter(..., 's')


Description

butter calculates a Butterworth filter. The result is given as zeros, poles and gain if there are three output arguments, or as numerator and denominator coefficient vectors if there are two output arguments.

butter(n,w0), where w0 is a scalar, gives a nth-order digital lowpass filter with a cutoff frequency of w0 relatively to half the sampling frequency.

butter(n,[wl,wh]), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandpass filter with passband between wl and wh relatively to half the sampling frequency.

butter(n,w0,'high') gives a nth-order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency.

butter(n,[wl,wh],'stop'), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency.

With an additional input argument which is the string 's', butter gives an analog Butterworth filter. Frequencies are given in rad/s.

cheb1ap

Chebyshev type 1 analog filter prototype.

Syntax

use filter
(z, p, k) = cheb1ap(n, rp)


Description

cheb1ap(n,rp) calculates the zeros, the poles, and the gain of a Chebyshev type 1 analog filter of degree n with a cutoff angular frequency of 1 rad/s. Ripples in the passband have a peak-to-peak magnitude of rp dB, i.e. the peak-to-peak ratio is 10^(rp/20).

cheb2ap

Chebyshev type 2 analog filter prototype.

Syntax

use filter
(z, p, k) = cheb2ap(n, rs)


Description

cheb2ap(n,rs) calculates the zeros, the poles, and the gain of a Chebyshev type 2 analog filter of degree n with a cutoff angular frequency of 1 rad/s. Ripples in the stopband have a peak-to-peak magnitude of rs dB, i.e. the peak-to-peak ratio is 10^(rs/20).

cheby1

Chebyshev type 1 filter.

Syntax

use filter
(z, p, k) = cheby1(n, rp, w0)
(num, den) = cheby1(n, rp, w0)
(...) = cheby1(n, rp, [wl, wh])
(...) = cheby1(n, rp, w0, 'high')
(...) = cheby1(n, rp, [wl, wh], 'stop')
(...) = cheby1(..., 's')


Description

cheby1 calculates a Chebyshev type 1 filter. The result is given as zeros, poles and gain if there are three output arguments, or as numerator and denominator coefficient vectors if there are two output arguments.

cheby1(n,rp,w0), where w0 is a scalar, gives a nth-order digital lowpass filter with a cutoff frequency of w0 relatively to half the sampling frequency. Ripples in the passband have a peak-to-peak magnitude of rp dB, i.e. the peak-to-peak ratio is 10^(rp/20).

cheby1(n,rp,[wl,wh]), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandpass filter with passband between wl and wh relatively to half the sampling frequency.

cheby1(n,rp,w0,'high') gives a nth-order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency.

cheby1(n,rp,[wl,wh],'stop'), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency.

With an additional input argument which is the string 's', cheby1 gives an analog Chebyshev type 1 filter. Frequencies are given in rad/s.

cheby2

Chebyshev type 2 filter.

Syntax

use filter
(z, p, k) = cheby2(n, rs, w0)
(num, den) = cheby2(n, rs, w0)
(...) = cheby2(n, rs, [wl, wh])
(...) = cheby2(n, rs, w0, 'high')
(...) = cheby2(n, rs, [wl, wh], 'stop')
(...) = cheby2(..., 's')


Description

cheby2 calculates a Chebyshev type 2 filter. The result is given as zeros, poles and gain if there are three output arguments, or as numerator and denominator coefficient vectors if there are two output arguments.

cheby2(n,rs,w0), where w0 is a scalar, gives a nth-order digital lowpass filter with a cutoff frequency of w0 relatively to half the sampling frequency. Ripples in the stopband have a peak-to-peak magnitude of rs dB, i.e. the peak-to-peak ratio is 10^(rs/20).

cheby2(n,rs,[wl,wh]), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandpass filter with passband between wl and wh relatively to half the sampling frequency.

cheby2(n,rs,w0,'high') gives a nth-order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency.

cheby2(n,rs,[wl,wh],'stop'), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency.

With an additional input argument which is the string 's', cheby2 gives an analog Chebyshev type 2 filter. Frequencies are given in rad/s.

ellip

Elliptic filter.

Syntax

use filter
(z, p, k) = ellip(n, rp, rs, w0)
(num, den) = ellip(n, rp, rs, w0)
(...) = ellip(n, rp, rs, [wl, wh])
(...) = ellip(n, rp, rs, w0, 'high')
(...) = ellip(n, rp, rs, [wl, wh], 'stop')
(...) = ellip(..., 's')


Description

ellip calculates a elliptic filter, or Cauer filter. The result is given as zeros, poles and gain if there are three output arguments, or as numerator and denominator coefficient vectors if there are two output arguments.

ellip(n,rp,rs,w0), where w0 is a scalar, gives a nth-order digital lowpass filter with a cutoff frequency of w0 relatively to half the sampling frequency. Ripples have a peak-to-peak magnitude of rp dB in the passband and of rs dB in the stopband (peak-to-peak ratios are respectively 10^(rp/20) and 10^(rs/20)).

ellip(n,rp,rs,[wl,wh]), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandpass filter with passband between wl and wh relatively to half the sampling frequency.

ellip(n,rp,rs,w0,'high') gives a nth-order digital highpass filter with a cutoff frequency of w0 relatively to half the sampling frequency.

ellip(n,rp,rs,[wl,wh],'stop'), where the second input argument is a vector of two numbers, gives a 2nth-order digital bandstop filter with stopband between wl and wh relatively to half the sampling frequency.

With an additional input argument which is the string 's', ellip gives an analog elliptic filter. Frequencies are given in rad/s.

ellipap

Elliptic analog filter prototype.

Syntax

use filter
(z, p, k) = ellipap(n, rp, rs)


Description

ellipap(n,rp,rs) calculates the zeros, the poles, and the gain of an elliptic analog filter of degree n with a cutoff angular frequency of 1 rad/s. Ripples have a peak-to-peak magnitude of rp dB in the passband and of rs dB in the stopband (peak-to-peak ratios are respectively 10^(rp/20) and 10^(rs/20)).

lp2bp

Lowpass prototype to bandpass filter conversion.

Syntax

use filter
(z, p, k) = lp2bp(z0, p0, k0, wc, ww)
(num, den) = lp2bp(num0, den0, wc, ww)


Description

lp2bp convert a lowpass analog filter prototype (with unit angular frequency) to a bandpass analog filter with the specified center angular frequency w0 and bandwidth ww. lp2bp(z0,p0,k0,wc,ww) converts a filter given by its zeros, poles, and gain; lp2bp(num0,den0,wc,ww) converts a filter given by its numerator and denominator coefficients in decreasing powers of s.

The new filter F(s) is

F(s) = F0((s^2 + wc^2 - ww^2/4)/(ww s))

where F0(s) is the filter prototype. The filter order is doubled.

lp2bs

Lowpass prototype to bandstop filter conversion.

Syntax

use filter
(z, p, k) = lp2bs(z0, p0, k0, wc, ww)
(num, den) = lp2bs(num0, den0, wc, ww)


Description

lp2bs convert a lowpass analog filter prototype (with unit angular frequency) to a bandstop analog filter with the specified center angular frequency w0 and bandwidth ww. lp2bs(z0,p0,k0,wc,ww) converts a filter given by its zeros, poles, and gain; lp2bs(num0,den0,wc,ww) converts a filter given by its numerator and denominator coefficients in decreasing powers of s.

The new filter F(s) is

F(s) = F0((ww s)/(s^2 + wc^2 - ww^2/4))

where F0(s) is the filter prototype. The filter order is doubled.

lp2hp

Lowpass prototype to highpass filter conversion.

Syntax

use filter
(z, p, k) = lp2hp(z0, p0, k0, w0)
(num, den) = lp2hp(num0, den0, w0)


Description

lp2hp convert a lowpass analog filter prototype (with unit angular frequency) to a highpass analog filter with the specified cutoff angular frequency w0. lp2hp(z0,p0,k0,w0) converts a filter given by its zeros, poles, and gain; lp2hp(num0,den0,w0) converts a filter given by its numerator and denominator coefficients in decreasing powers of s.

The new filter F(s) is

F(s) = F0\left(1/w0 s\right)

where F0(s) is the filter prototype.

lp2lp

Lowpass prototype to lowpass filter conversion.

Syntax

use filter
(z, p, k) = lp2lp(z0, p0, k0, w0)
(num, den) = lp2lp(num0, den0, w0)


Description

lp2lp convert a lowpass analog filter prototype (with unit angular frequency) to a lowpass analog filter with the specified cutoff angular frequency w0. lp2lp(z0,p0,k0,w0) converts a filter given by its zeros, poles, and gain; lp2lp(num0,den0,w0) converts a filter given by its numerator and denominator coefficients in decreasing powers of s.

The new filter F(s) is

F(s) = F0(s/w0)

where F0(s) is the filter prototype.