# butter

Butterworth IIR digital filter design

## Syntax

``butterFilter = butter(designSpecs,'SystemObject',true)``
``````butterFilter = butter(designSpecs,designoption,value,... 'SystemObject',true)``````
``butterFilter = design(designSpecs,'butter','SystemObject',true)``

## Description

````butterFilter = butter(designSpecs,'SystemObject',true)` designs a butterworth IIR digital filter using specifications in the object `designSpecs`.Depending on the filter specification object `designSpecs`, the `butter` design method might not be valid. Use `designmethods` with the filter specification object to determine if a butterworth IIR digital filter design is possible. designmethods(designSpecs,'Systemobject',true) ```
``````butterFilter = butter(designSpecs,designoption,value,... 'SystemObject',true)``` returns a butterworth IIR filter with one or more specified designed options and the corresponding values.To view a list of available design options, run the `designoptions` function on the specification object. The function also lists the default design options the filter uses. designoptions(designSpecs,'butter') ```

example

````butterFilter = design(designSpecs,'butter','SystemObject',true)` is an alternative syntax for designing the butterworth IIR digital filter.For complete help about using the `butter` design method for a specification object, `designSpecs`, enter the following at the MATLAB® command prompt. help(designSpecs,'butter') ```

## Examples

collapse all

Design a butterworth filter with lowpass and highpass frequency responses. The filter design procedure is:

1. Specify the filter design specifications using a `fdesign` function.

2. Pick a design method provided by the `designmethods` function.

3. To determine the available design options to choose from, use the `designoptions` function.

4. Design the filter using the `design` function.

Lowpass Filter

Construct a default lowpass filter design specification object using `fdesign.lowpass`.

`designSpecs = fdesign.lowpass`
```designSpecs = lowpass with properties: Response: 'Lowpass' Specification: 'Fp,Fst,Ap,Ast' Description: {4x1 cell} NormalizedFrequency: 1 Fpass: 0.4500 Fstop: 0.5500 Apass: 1 Astop: 60 ```

Determine the available design methods using the `designmethods` function. To design a butterworth filter, pick `butter`.

`designmethods(designSpecs,'SystemObject',true)`
```Design Methods that support System objects for class fdesign.lowpass (Fp,Fst,Ap,Ast): butter cheby1 cheby2 ellip equiripple ifir kaiserwin multistage ```

While designing the filter, you can specify additional design options. View a list of the options using the `designoptions` function. This function also shows the default design options the filter uses.

`designoptions(designSpecs,'butter','SystemObject',true)`
```ans = struct with fields: FilterStructure: {1x6 cell} SOSScaleNorm: 'ustring' SOSScaleOpts: 'fdopts.sosscaling' MatchExactly: {'passband' 'stopband'} DefaultFilterStructure: 'df2sos' DefaultMatchExactly: 'stopband' DefaultSOSScaleNorm: '' DefaultSOSScaleOpts: [1x1 fdopts.sosscaling] ```

Use the `design` function to design the filter. Pass `'butter'` and the specifications given by variable `designSpecs`, as input arguments. Specify the `'matchexactly'` design option to `'passband'`.

`lpFilter = design(designSpecs,'butter','matchexactly','passband','SystemObject',true);`

Visualize the frequency response of the designed filter.

`fvtool(lpFilter)`

Highpass Filter

Construct a highpass filter design specification object using `fdesign.highpass`. Specify the order to be 7 and the 3 dB frequency to be $0.6\pi$ radians/sample.

`designSpecs = fdesign.highpass('N,F3dB',7,.6); `

Determine the available design methods. To design a butterworth filter, pick `butter`.

`designmethods(designSpecs,'SystemObject',true)`
```Design Methods that support System objects for class fdesign.highpass (N,F3dB): butter maxflat ```

While designing the filter, you can specify additional design options. View a list of the options using the `designoptions` function. This function also shows the default design options the filter uses.

`designoptions(designSpecs,'butter','SystemObject',true)`
```ans = struct with fields: FilterStructure: {1x6 cell} SOSScaleNorm: 'ustring' SOSScaleOpts: 'fdopts.sosscaling' DefaultFilterStructure: 'df2sos' DefaultSOSScaleNorm: '' DefaultSOSScaleOpts: [1x1 fdopts.sosscaling] ```

To design the butterworth filter, use the `design` function and specify `'butter'` as an input. Set `'FilterStructure'` to `'cascadeallpass'`.

`hpFilter = design(designSpecs,'butter','FilterStructure','cascadeallpass','SystemObject',true);`

Visualize the highpass frequency response.

`fvtool(hpFilter)`

collapse all

## Output Arguments

collapse all

Butterworth IIR filter, returned as a filter System object. The System object and the values of its properties depend on the input `designSpecs` object and the other design options specified to the function.

Introduced in R2011a

Get trial now