# butter

Create a Butterworth filter.

## Syntax

[b,a] = butter(n,Wp)

[b,a] = butter(n,Wp,band)

[b,a] = butter(n,Wp,domain)

[b,a] = butter(n,Wp,band,domain)

## Inputs

n
The filter order.
Type: integer
Dimension: scalar
Wp
A scalar specifying the 3dB cutoff frequency of a low or high pass filter, or a two element vector specifying the cutoff frequencies of a bandpass or bandstop filter. For a digital filter the values (in Hz) are normalized relative to the Nyquist frequency. For an analog filter the values are in radians/sec.
Type: double
Dimension: scalar | vector
band
The band type of the filter. Omit for low pass or bandpass. Use 'high' for high pass, and 'stop' for bandstop.
Type: string
domain
• Use 'z' for digital filters (default).
• Use 's' for analog filters.

## Outputs

b
The numerator polynomial coefficients of the filter.
Type: vector
a
The denominator polynomial coefficients of the filter.
Type: vector

## Examples

Create a fourth order Butterworth low pass digital filter with a 300 Hz cutoff frequency and a 1000 Hz sampling frequency.

[b,a] = butter(4,300/500)
b = [Matrix] 1 x 5
0.16718  0.66872  1.00308  0.66872  0.16718
a = [Matrix] 1 x 5
1.00000  0.78210  0.67998  0.18268  0.03012

Create a fourth order Butterworth high pass digital filter with a 300 Hz cutoff frequency and a 1000 Hz sampling frequency.

[b,a] = butter(4,300/500,'high')
b = [Matrix] 1 x 5
0.04658  -0.18633  0.27950  -0.18633  0.04658
a = [Matrix] 1 x 5
1.00000  0.78210  0.67998  0.18268  0.03012

Create a fourth order Butterworth bandstop digital filter with a 300 Hz low cutoff frequency, a 400 Hz high cutoff frequency and a 1000 Hz sampling frequency.

[b,a] = butter(4,[300/500 400/500],'stop')
b = [Matrix] 1 x 9
0.43285  2.14011  5.69937  9.69013  11.54347  9.69013  5.69937  2.14011  0.43285
a = [Matrix] 1 x 9
1.00000  3.93658  8.26039  11.21743  10.78363  7.39144  3.57650  1.11505  0.18738

Create a fourth order Butterworth bandstop analog filter with a 300 Hz low cutoff frequency, a 400 Hz high cutoff frequency and a 1000 Hz sampling frequency.

[b,a] = butter(4,[300/500 400/500],'stop','s')
b = [Matrix] 1 x 9
1.00000  0.00000  1.92000  0.00000  1.38240  0.00000  0.44237  0.00000  0.05308
a = [Matrix] 1 x 9
1.00000  0.52263  2.05657  0.77349  1.51511  0.37127  0.47383  0.05780  0.05308