# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# fdesign.bandpass

Bandpass filter specification object

## Syntax

D = fdesign.bandpassD = fdesign.bandpass(SPEC)D = fdesign.bandpass(spec,specvalue1,specvalue2,...)D = fdesign.bandpass(specvalue1,specvalue2,specvalue3,specvalue4,...specvalue4,specvalue5,specvalue6)D = fdesign.bandpass(...,Fs)D = fdesign.bandpass(...,MAGUNITS)

## Description

D = fdesign.bandpass constructs a bandpass filter specification object D, applying default values for the properties Fstop1, Fpass1, Fpass2, Fstop2, Astop1, Apass, and Astop2 — one possible set of values you use to specify a bandpass filter.

D = fdesign.bandpass(SPEC) constructs object D and sets its Specification property to SPEC. Entries in the SPEC represent various filter response features, such as the filter order, that govern the filter design. Valid entries for SPEC are shown below and used to define the bandpass filter. These entries are not case sensitive.

 Note:   Specifications marked with an asterisk require the DSP System Toolbox™ software.
• 'Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2' (default spec)

• 'N,F3dB1,F3dB2'

• "N,F3dB1,F3dB2,Ap' *

• 'N,F3dB1,F3dB2,Ast' *

• 'N,F3dB1,F3dB2,Ast1,Ap,Ast2' *

• 'N,F3dB1,F3dB2,BWp *

• 'N,F3dB1,F3dB2,BWst' *

• 'N,Fc1,Fc2'

• 'N,Fc1,Fc2,Ast1,Ap,Ast2'

• 'N,Fp1,Fp2,Ap'

• 'N,Fp1,Fp2,Ast1,Ap,Ast2'

• 'N,Fst1,Fp1,Fp2,Fst2'

• 'N,Fst1,Fp1,Fp2,Fst2,C' *

• 'N,Fst1,Fp1,Fp2,Fst2,Ap' *

• 'N,Fst1,Fst2,Ast'

• 'Nb,Na,Fst1,Fp1,Fp2,Fst2' *

The filter specifications are defined as follows:

• Ap — amount of ripple allowed in the pass band. Also called Apass.

• Ast1 — attenuation in the first stop band in decibels (the default units). Also called Astop1.

• Ast2 — attenuation in the second stop band in decibels (the default units). Also called Astop2.

• BWp — bandwidth of the filter passband. Specified in normalized frequency units.

• BWst — bandwidth of the filter stopband. Specified in normalized frequency units.

• C — Constrained band flag. This enables you to specify passband ripple or stopband attenuation for fixed-order designs in one or two of the three bands.

In the specification 'N,Fst1,Fp1,Fp2,Fst2,C', you cannot specify constraints in both stopbands and the passband simultaneously. You can specify constraints in any one or two bands.

• F3dB1 — cutoff frequency for the point 3 dB point below the passband value for the first cutoff. Specified in normalized frequency units. (IIR filters)

• F3dB2 — cutoff frequency for the point 3 dB point below the passband value for the second cutoff. Specified in normalized frequency units. (IIR filters)

• Fc1 — cutoff frequency for the point 6 dB point below the passband value for the first cutoff. Specified in normalized frequency units. (FIR filters)

• Fc2 — cutoff frequency for the point 6 dB point below the passband value for the second cutoff. Specified in normalized frequency units. (FIR filters)

• Fp1 — frequency at the edge of the start of the pass band. Specified in normalized frequency units. Also called Fpass1.

• Fp2 — frequency at the edge of the end of the pass band. Specified in normalized frequency units. Also called Fpass2.

• Fst1 — frequency at the edge of the start of the first stop band. Specified in normalized frequency units. Also called Fstop1.

• Fst2 — frequency at the edge of the start of the second stop band. Specified in normalized frequency units. Also called Fstop2.

• N — filter order for FIR filters. Or both the numerator and denominator orders for IIR filters when na and nb are not provided.

• Na — denominator order for IIR filters

• Nb — numerator order for IIR filters

Graphically, the filter specifications look similar to those shown in the following figure.

Regions between specification values like Fst1 and Fp1 are transition regions where the filter response is not explicitly defined.

The filter design methods that apply to a bandpass filter specification object change depending on the Specification. Use designmethods to determine which design methods apply to an object and the Specification property value.

Use designopts to determine the design options for a given design method. Enter help(D,METHOD) at the MATLAB® command line to obtain detailed help on the design options for a given design method, METHOD.

D = fdesign.bandpass(spec,specvalue1,specvalue2,...) constructs an object D and sets its specifications at construction time.

D = fdesign.bandpass(specvalue1,specvalue2,specvalue3,specvalue4,...specvalue4,specvalue5,specvalue6) constructs Dwith the default Specification property, using the values you provide as input arguments for specvalue1,specvalue2,specvalue3,specvalue4,specvalue4,specvalue5, specvalue6 and specvalue7.

D = fdesign.bandpass(...,Fs) adds the argument Fs, specified in Hz to define the sampling frequency to use. In this case, all frequencies in the specifications are in Hz as well.

D = fdesign.bandpass(...,MAGUNITS) specifies the units for any magnitude specification you provide in the input arguments. MAGUNITS can be one of

• 'linear' — specify the magnitude in linear units

• 'dB' — specify the magnitude in dB (decibels)

• 'squared' — specify the magnitude in power units

When you omit the MAGUNITS argument, fdesign assumes that all magnitudes are in decibels. Note that fdesign stores all magnitude specifications in decibels (converting to decibels when necessary) regardless of how you specify the magnitudes.

## Examples

collapse all

Filter a discrete-time signal with a bandpass filter. The signal is a sum of three discrete-time sinusoids, π/8, π/2, and 3π/4 rad/sample.

n = 0:159; x = cos(pi/8*n)+cos(pi/2*n)+sin(3*pi/4*n); 

Design an FIR equiripple bandpass filter to remove the lowest and highest discrete-time sinusoids. View the frequency response of the filter.

d = fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2', ... 1/4,3/8,5/8,6/8,60,1,60); Hd = design(d,'equiripple'); freqz(Hd) 

Apply the filter to the discrete-time signal. Plot the original and filtered signals in the frequency domain.

y = filter(Hd,x); freq = 0:(2*pi)/length(x):pi; xdft = fft(x); ydft = fft(y); plot(freq/pi,abs(xdft(1:length(x)/2+1))) hold on plot(freq/pi,abs(ydft(1:length(x)/2+1))) hold off xlabel('Normalized Frequency (\times\pi rad/sample)') legend('Original Signal','Bandpass Signal') 

Design an IIR Butterworth filter of order 10 with 3-dB frequencies of 1 and 1.2 kHz. The sample rate is 10 kHz. Visualize the frequency response of the filter.

d = fdesign.bandpass('N,F3dB1,F3dB2',10,1e3,1.2e3,1e4); Hd = design(d,'butter'); fvtool(Hd) 

Design a constrained-band FIR equiripple filter of order 100 with a passband of [1, 1.4] kHz. Both stopband attenuation values are constrained to 60 dB. The sample rate is 10 kHz.

d = fdesign.bandpass('N,Fst1,Fp1,Fp2,Fst2,C',100,800,1e3,1.4e3,1.6e3,1e4); d.Stopband1Constrained = true; d.Astop1 = 60; d.Stopband2Constrained = true; d.Astop2 = 60; Hd = design(d,'equiripple'); 

Visualize and measure the magnitude response of the filter.

fvtool(Hd) measure(Hd) 
ans = Sample Rate : 10 kHz First Stopband Edge : 800 Hz First 6-dB Point : 946.7621 Hz First 3-dB Point : 975.1807 Hz First Passband Edge : 1 kHz Second Passband Edge : 1.4 kHz Second 3-dB Point : 1.4248 kHz Second 6-dB Point : 1.4533 kHz Second Stopband Edge : 1.6 kHz First Stopband Atten. : 60.0614 dB Passband Ripple : 2.1443 dB Second Stopband Atten. : 60.0399 dB First Transition Width : 200 Hz Second Transition Width : 200 Hz 

The passband ripple is slightly over 2 dB. Because the design constrains both stopbands, you cannot constrain the passband ripple.