# iirnotch

(To be removed) Second-order IIR notch filter

The `iirnotch` function will be removed in a future release. Use the `designNotchPeakIIR` function instead. For more information on how to update your existing code, see Compatibility Considerations.

## Syntax

``[num,den] = iirnotch(w0,bw)``
``[num,den] = iirnotch(w0,bw,ab)``

## Description

example

````[num,den] = iirnotch(w0,bw)` returns the numerator coefficients, `num`, and the denominator coefficients, `den`, of the digital notching filter with the notch located at `w0` and the bandwidth at the –3 dB point set to `bw`. To design the filter, `w0` must meet the condition 0.0 < `w0` < 1.0, where 1.0 corresponds to π radians per sample in the frequency range.The quality factor (Q factor) q for the filter is related to the filter bandwidth by q = `w0/bw`, where `w0` is the notch frequency.```
````[num,den] = iirnotch(w0,bw,ab)` returns the digital notching filter whose bandwidth, `bw`, is specified at a level of –`ab` decibels.```

## Examples

collapse all

Design and plot an IIR notch filter that removes a 60 Hz tone (f0) from a signal at 300 Hz (fs). For this example, set the Q factor for the filter to 35 and use it to specify the filter bandwidth.

```wo = 60/(300/2); bw = wo/35; [b,a] = iirnotch(wo,bw);```

Visualize the magnitude response.

The notch filter has the desired bandwidth with the notch located at 60 Hz, or $0.4\pi$ radians per sample.

`filterAnalyzer(b,a)`

## Input Arguments

collapse all

Notch frequency, specified as a positive scalar in the range (0.0, 1.0), where 1.0 corresponds to π radians per sample in the frequency range.

Data Types: `single` | `double`

Bandwidth at the –3 dB point, specified as a positive scalar in the range (0.0, 1.0).

The quality factor (Q factor) q for the filter is related to the filter bandwidth by q = `w0/bw`, where `w0` is the notch frequency.

Data Types: `single` | `double`

Custom decibel level, –`ab`, at which the filter has a bandwidth of `bw`. Including the optional input argument `ab` lets you specify the magnitude response bandwidth at a level that is not the default –3 dB point, such as –6 dB or 0 dB. If not specified, `ab` defaults to the –3 dB width (10log10(1/2)).

Data Types: `single` | `double`

## Output Arguments

collapse all

Numerator coefficients of the designed notch filter, returned as a row vector.

Data Types: `double`

Denominator coefficients of the designed notch filter, returned as a row vector.

Data Types: `double`

## Version History

Introduced in R2011a

collapse all

### R2024a: `iirnotch` will be removed

The `iirnotch` function will be removed in a future release. Existing instances of the function continue to run. For new code, use the `designNotchPeakIIR` function instead.

Update Code

This table shows how the function is typically used and explains how to update the existing code to use the `designNotchPeakIIR` function.

Discouraged UsageRecommended Replacement

Notch frequency is $0.4\pi$ radians per sample. Quality factor is 35.

```wo = 60/(300/2); bw = wo/35; [b,a] = iirnotch(wo,bw);```
```[b,a] = designNotchPeakIIR(CenterFrequency=wo,... Bandwidth=bw,Response="notch");```

or

```[b,a] = designNotchPeakIIR(CenterFrequency=wo,... QualityFactor=35,Response="notch");```