Main Content

ellip

Elliptic filter design

Description

example

[b,a] = ellip(n,Rp,Rs,Wp)returns the transfer function coefficients of annth-order lowpass digital elliptic filter with normalized passband edge frequencyWp. The resulting filter hasRpdecibels of peak-to-peak passband ripple andRsdecibels of stopband attenuation down from the peak passband value.

example

[b,a] = ellip(n,Rp,Rs,Wp,ftype)设计低通、高通、带通或bandstopelliptic filter, depending on the value offtypeand the number of elements ofWp. The resulting bandpass and bandstop designs are of order 2n.

Note:See限制for information about numerical issues that affect forming the transfer function.

example

[z,p,k] = ellip(___)设计低通、高通、带通或bandstopdigital elliptic filter and returns its zeros, poles, and gain. This syntax can include any of the input arguments in previous syntaxes.

example

[A,B,C,D] = ellip(___)设计低通、高通、带通或bandstopdigital elliptic filter and returns the matrices that specify its state-space representation.

example

[___] = ellip(___,'s')设计低通、高通、带通或bandstopanalog elliptic filter with passband edge angular frequencyWp,Rpdecibels of passband ripple, andRsdecibels of stopband attenuation.

Examples

collapse all

Design a 6th-order lowpass elliptic filter with 5 dB of passband ripple, 40 dB of stopband attenuation, and a passband edge frequency of 300 Hz, which, for data sampled at 1000 Hz, corresponds to 0 . 6 π rad/sample. Plot its magnitude and phase responses. Use it to filter a 1000-sample random signal.

[b,a] = ellip(6,5,40,0.6); freqz(b,a)

Figure contains 2 axes objects. Axes object 1 contains an object of type line. Axes object 2 contains an object of type line.

dataIn = randn(1000,1); dataOut = filter(b,a,dataIn);

Design a 6th-order elliptic bandstop filter with normalized edge frequencies of 0 . 2 π and 0 . 6 π rad/sample, 5 dB of passband ripple, and 50 dB of stopband attenuation. Plot its magnitude and phase responses. Use it to filter random data.

[b,a] = ellip(3,5,50,[0.2 0.6],“停止”); freqz(b,a)

Figure contains 2 axes objects. Axes object 1 contains an object of type line. Axes object 2 contains an object of type line.

dataIn = randn(1000,1); dataOut = filter(b,a,dataIn);

Design a 6th-order highpass elliptic filter with a passband edge frequency of 300 Hz, which, for data sampled at 1000 Hz, corresponds to 0 . 6 π rad/sample. Specify 3 dB of passband ripple and 50 dB of stopband attenuation. Plot the magnitude and phase responses. Convert the zeros, poles, and gain to second-order sections for use byfvtool.

[z,p,k] = ellip(6,3,50,300/500,'high'); sos = zp2sos(z,p,k); fvtool(sos,'Analysis','freq')

Figure Filter Visualization Tool - Magnitude Response (dB) and Phase Response contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) and Phase Response contains an object of type line.

Design a 20th-order elliptic bandpass filter with a lower passband frequency of 500 Hz and a higher passband frequency of 560 Hz. Specify a passband ripple of 3 dB, a stopband attenuation of 40 dB, and a sample rate of 1500 Hz. Use the state-space representation. Design an identical filter usingdesignfilt.

[A, B, C, D] = ellip(10, 3、40 (500 - 560)/ 750);d =德西gnfilt('bandpassiir','FilterOrder',20,...'PassbandFrequency1',500,'PassbandFrequency2',560,...'PassbandRipple',3,...'StopbandAttenuation1',40,'StopbandAttenuation2',40,...'SampleRate',1500);

Convert the state-space representation to second-order sections. Visualize the frequency responses usingfvtool.

sos = ss2sos(A,B,C,D); fvt = fvtool(sos,d,'Fs',1500); legend(fvt,'ellip','designfilt')

Figure Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line. These objects represent ellip, designfilt.

Design a 5th-order analog Butterworth lowpass filter with a cutoff frequency of 2 GHz. Multiply by 2 π to convert the frequency to radians per second. Compute the frequency response of the filter at 4096 points.

n = 5; f = 2e9; [zb,pb,kb] = butter(n,2*pi*f,'s'); [bb,ab] = zp2tf(zb,pb,kb); [hb,wb] = freqs(bb,ab,4096);

Design a 5th-order Chebyshev Type I filter with the same edge frequency and 3 dB of passband ripple. Compute its frequency response.

[z1,p1,k1] = cheby1(n,3,2*pi*f,'s'); [b1,a1] = zp2tf(z1,p1,k1); [h1,w1] = freqs(b1,a1,4096);

Design a 5th-order Chebyshev Type II filter with the same edge frequency and 30 dB of stopband attenuation. Compute its frequency response.

[z2,p2,k2] = cheby2(n,30,2*pi*f,'s'); [b2,a2] = zp2tf(z2,p2,k2); [h2,w2] = freqs(b2,a2,4096);

Design a 5th-order elliptic filter with the same edge frequency, 3 dB of passband ripple, and 30 dB of stopband attenuation. Compute its frequency response.

[ze,pe,ke] = ellip(n,3,30,2*pi*f,'s'); [be,ae] = zp2tf(ze,pe,ke); [he,we] = freqs(be,ae,4096);

Plot the attenuation in decibels. Express the frequency in gigahertz. Compare the filters.

plot(wb/(2e9*pi),mag2db(abs(hb))) holdonplot(w1/(2e9*pi),mag2db(abs(h1))) plot(w2/(2e9*pi),mag2db(abs(h2))) plot(we/(2e9*pi),mag2db(abs(he))) axis([0 4 -40 5]) grid xlabel('Frequency (GHz)') ylabel('Attenuation (dB)') legend('butter','cheby1','cheby2','ellip')

Figure contains an axes object. The axes object contains 4 objects of type line. These objects represent butter, cheby1, cheby2, ellip.

The Butterworth and Chebyshev Type II filters have flat passbands and wide transition bands. The Chebyshev Type I and elliptic filters roll off faster but have passband ripple. The frequency input to the Chebyshev Type II design function sets the beginning of the stopband rather than the end of the passband.

Input Arguments

collapse all

Filter order, specified as an integer scalar. For bandpass and bandstop designs,nrepresents one-half the filter order.

Data Types:double

Peak-to-peak passband ripple, specified as a positive scalar expressed in decibels.

If your specification, ℓ, is in linear units, you can convert it to decibels usingRp= 40 log10((1+ℓ)/(1–ℓ)).

Data Types:double

Stopband attenuation down from the peak passband value, specified as a positive scalar expressed in decibels.

If your specification, ℓ, is in linear units, you can convert it to decibels usingRs= –20 log10ℓ.

Data Types:double

Passband edge frequency, specified as a scalar or a two-element vector. The passband edge frequency is the frequency at which the magnitude response of the filter isRpdecibels. Smaller values of passband ripple,Rp, and larger values of stopband attenuation,Rs, both result in wider transition bands.

  • IfWpis a scalar, thenellipdesigns a lowpass or highpass filter with edge frequencyWp.

    IfWpis the two-element vector[w1 w2], wherew1<w2, thenellipdesigns a bandpass or bandstop filter with lower edge frequencyw1and higher edge frequencyw2.

  • For digital filters, the passband edge frequencies must lie between 0 and 1, where 1 corresponds to the Nyquist rate—half the sample rate orπrad/sample.

    For analog filters, the passband edge frequencies must be expressed in radians per second and can take on any positive value.

Data Types:double

Filter type, specified as one of the following:

  • 'low'specifies a lowpass filter with passband edge frequencyWp.'low'is the default for scalarWp.

  • 'high'specifies a highpass filter with passband edge frequencyWp.

  • 'bandpass'specifies a bandpass filter of order 2nifWpis a two-element vector.'bandpass'is the default whenWphas two elements.

  • “停止”specifies a bandstop filter of order 2nifWpis a two-element vector.

Output Arguments

collapse all

Transfer function coefficients of the filter, returned as row vectors of lengthn+ 1 for lowpass and highpass filters and 2n+ 1 for bandpass and bandstop filters.

  • For digital filters, the transfer function is expressed in terms ofbandaas

    H ( z ) = B ( z ) A ( z ) = b(1) + b(2) z 1 + + b(n+1) z n a(1) + a(2) z 1 + + a(n+1) z n .

  • For analog filters, the transfer function is expressed in terms ofbandaas

    H ( s ) = B ( s ) A ( s ) = b(1) s n + b(2) s n 1 + + b(n+1) a(1) s n + a(2) s n 1 + + a(n+1) .

Data Types:double

Zeros, poles, and gain of the filter, returned as two column vectors of lengthn(2nfor bandpass and bandstop designs) and a scalar.

  • For digital filters, the transfer function is expressed in terms ofz,p, andkas

    H ( z ) = k ( 1 z(1) z 1 ) ( 1 z(2) z 1 ) ( 1 z(n) z 1 ) ( 1 p(1) z 1 ) ( 1 p(2) z 1 ) ( 1 p(n) z 1 ) .

  • For analog filters, the transfer function is expressed in terms ofz,p, andkas

    H ( s ) = k ( s z(1) ) ( s z(2) ) ( s z(n) ) ( s p(1) ) ( s p(2) ) ( s p(n) ) .

Data Types:double

State-space representation of the filter, returned as matrices. Ifm=nfor lowpass and highpass designs andm= 2nfor bandpass and bandstop filters, thenAism×m,Bism× 1,Cis 1 ×m, andDis 1 × 1.

  • For digital filters, the state-space matrices relate the state vectorx, the inputu, and the outputythrough

    x ( k + 1 ) = A x ( k ) + B u ( k ) y ( k ) = C x ( k ) + D u ( k ) .

  • For analog filters, the state-space matrices relate the state vectorx, the inputu, and the outputythrough

    x ˙ = A x + B u y = C x + D u .

Data Types:double

More About

collapse all

限制

Numerical Instability of Transfer Function Syntax

In general, use the[z,p,k]syntax to design IIR filters. To analyze or implement your filter, you can then use the[z,p,k]output withzp2sos. If you design the filter using the[b,a]syntax, you might encounter numerical problems. These problems are due to round-off errors and can occur fornas low as 4. The following example illustrates this limitation.

n = 6; Rp = 0.1; Rs = 80; Wn = [2.5e6 29e6]/500e6; ftype ='bandpass';% Transfer Function design[b,a] = ellip(n,Rp,Rs,Wn,ftype);% This filter is unstable% Zero-Pole-Gain design[z,p,k] = ellip(n,Rp,Rs,Wn,ftype); sos = zp2sos(z,p,k);% Plot and compare the resultshfvt = fvtool(b,a,sos,'FrequencyScale','log'); legend(hfvt,'TF Design','ZPK Design')

Figure Filter Visualization Tool - Magnitude Response (dB) contains an axes object and other objects of type uitoolbar, uimenu. The axes object with title Magnitude Response (dB) contains 2 objects of type line. These objects represent TF Design, ZPK Design.

Algorithms

Elliptic filters offer steeper rolloff characteristics than Butterworth or Chebyshev filters, but are equiripple in both the passband and the stopband. In general, elliptic filters meet given performance specifications with the lowest order of any filter type.

ellipuses a five-step algorithm:

  1. It finds the lowpass analog prototype poles, zeros, and gain using the functionellipap.

  2. It converts the poles, zeros, and gain into state-space form.

  3. If required, it uses a state-space transformation to convert the lowpass filter to a bandpass, highpass, or bandstop filter with the desired frequency constraints.

  4. For digital filter design, it usesbilinearto convert the analog filter into a digital filter through a bilinear transformation with frequency prewarping. Careful frequency adjustment enables the analog filters and the digital filters to have the same frequency response magnitude atWporw1andw2.

  5. It converts the state-space filter back to transfer function or zero-pole-gain form, as required.

Extended Capabilities

Introduced before R2006a