# buttord

Design a Butterworth filter.

## Syntax

[n,Wn] = buttord(Wp,Ws,Rp,Rs,domain)

## Inputs

`Wp`- A scalar specifying the passband frequency of a low or high pass filter, or a two element vector specifying the passband 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.
`Ws`- A scalar specifying the stopband frequency of a low or high pass filter, or a two element vector specifying the stopband 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.
`Rp`- The maximum attenuation in decibels at
`Wp`. `Rs`- The minimum attenuation in decibels at
`Ws`. `domain`-
- Use 'z' for digital filters (default).
- Use 's' for analog filters.

## Outputs

- n
- The lowest filter order that will meet the requirements.
- Wn
- Normalized frequency input for which the requirement is met.

## Examples

Design a digital Butterworth filter with no more than 1 dB attenuation at 100 Hz and at least 20 dB attenuation at 200 Hz, with a 1000 Hz sampling frequency.

`[n,Wn] = buttord(100/500, 200/500, 1, 20)`

` ````
n = 4
Wn = 0.2338
```

Design a digital Butterworth filter with no more than 1 dB attenuation with a passband from 100 Hz to 150 Hz, and at least 20 dB attenuation in the stopband from 50 Hz to 300 Hz, with a 1000 Hz sampling frequency.

`[n,Wn] = buttord([100 150]/500, [50 300]/500, 1, 20)`

` ````
n = 2
Wn = [Matrix] 1 x 2
0.18413 0.32322
```

Design an analog Butterworth filter with no more than 1 dB attenuation with a passband from 100 Hz to 150 Hz, and at least 20 dB attenuation in the stopband from 50 Hz to 300 Hz, with a 1000 Hz sampling frequency.

`[n,Wn] = buttord([100 150]/500, [50 300]/500, 1, 20, 's')`

` ````
n = 2
Wn = [Matrix] 1 x 2
0.18469 0.32487
```

## Comments

In general, there are a range of corner frequencies for which the requirements can be met
at the lowest order. If `Rp` ~= 3.0103 (the half-power point) then
`Wp` is the smallest passband meeting the design requirement.
`Wn` is the largest passband meeting the design requirement.