# fdesign.notch

Notch filter specification

## Syntax

``notchSpecs = fdesign.notch``
``notchSpecs = fdesign.notch(n,f0,q)``
``notchSpecs = fdesign.notch(spec,value1,...,valueN)``
``notchSpecs = fdesign.notch(___,Fs)``
``notchSpecs = fdesign.notch(___,magunits)``

## Description

The `fdesign.notch` function returns a `notch` filter design specification object that contains the specifications for a filter, such as passband ripple, stopband attenuation, and filter order. Then, use the `design` function to design the filter from the filter design specifications object.

For more control options, see Filter Design Procedure. For a complete workflow, see Design a Filter in Fdesign — Process Overview.

````notchSpecs = fdesign.notch` constructs a notch filter specification object with the filter order set to 10, center frequency set to 0.5, and quality factor set to 2.5.```
````notchSpecs = fdesign.notch(n,f0,q)` constructs a notch filter specification object with the filter order, center frequency, and quality factor specified by `n`,`f0`, and `q`, respectively.```

example

````notchSpecs = fdesign.notch(spec,value1,...,valueN)` constructs a notch filter specification object with a particular filter order, center frequency, and other specification options. Indicate the options you want to specify in the expression `spec`. After the expression, specify a value for each option.```
````notchSpecs = fdesign.notch(___,Fs)` provides the sample rate of the signal to be filtered.```
````notchSpecs = fdesign.notch(___,magunits)` provides the units for any magnitude specification given. `magunits` can be one of the following: `'linear'`, `'dB'`, or `'squared'`. If this argument is omitted, `'dB'` is assumed. The magnitude specifications are always converted and stored in decibels regardless of how they were specified. If `Fs` is provided, `magunits` must follow `Fs` in the input argument list.```

## Examples

collapse all

Design a direct-form I notching filter that has a filter order of 6, center frequency of 0.5, quality factor of 10, and a passband ripple of 1 dB.

Create a `notch` filter design specification object using the `fdesign.notch` function and specify these design parameters.

`notchSpecs = fdesign.notch('N,F0,Q,Ap',6,0.5,10,1);`

Design the notch filter using the `design` function. The resulting filter is a `dsp.BiquadFilter` System object™. For details on how to apply this filter on streaming data, refer to `dsp.BiquadFilter`.

`notchFilt = design(notchSpecs,'SystemObject',true)`
```notchFilt = dsp.BiquadFilter with properties: Structure: 'Direct form II' SOSMatrixSource: 'Property' SOSMatrix: [3x6 double] ScaleValues: [4x1 double] InitialConditions: 0 OptimizeUnityScaleValues: true Show all properties ```

Visualize the frequency response of the designed filter using `fvtool`.

`fvtool(notchFilt)`

## Input Arguments

collapse all

Specification expression, specified as one of these character vectors:

• `'N,F0,Q'` (default)

• `'N,F0,Q,Ap'`

• `'N,F0,Q,Ast'`

• `'N,F0,Q,Ap,Ast'`

• `'N,F0,BW'`

• `'N,F0,BW,Ap'`

• `'N,F0,BW,Ast'`

• `'N,F0,BW,Ap,Ast'`

This table describes each option that can appear in the expression.

Specification optionDescription
`N`Filter order (must be even)
`F0`Center frequency
`Q`Quality factor
`BW`3 dB bandwidth
`Ap`Passband ripple (dB)
`Ast`Stopband attenuation (dB)

The design methods available for designing the filter depend on the specification expression. You can obtain these methods using the `designmethods` function. The table lists each specification expression supported by `fdesign.notch` and the corresponding design methods available.

Specification expressionSupported design methodFilter description
`'N,F0,Q'``butter`

Butterworth digital filter

`'N,F0,Q,Ap'``cheby1`

Chebyshev Type I digital filter

`'N,F0,Q,Ast'``cheby2`

Chebyshev Type II digital filter

`'N,F0,Q,Ap,Ast'``ellip`

Elliptical digital filter

`'N,F0,BW'``butter`

Butterworth digital filter

`'N,F0,BW,Ap'``cheby1`

Chebyshev Type I digital filter

`'N,F0,BW,Ast'``cheby2`

Chebyshev Type II digital filter

`'N,F0,BW,Ap,Ast'``ellip`

Elliptical digital filter

To design the filter, call the `design` function with one of these design methods as an input. You can choose the type of filter response by passing `'FIR'` or `'IIR'` to the `design` function. For more details, see `design`.

For more details on the procedure, see Filter Design Procedure. For an example, see Design Notch Filter.

Specification values, specified as a comma-separated list of values. Specify a value for each option in `spec` in the same order that the options appear in the expression.

Example: ```d = fdesign.notch('N,F0,BW,Ast',n,f0,bw,ast)```

The arguments below describe more details for each option in the expression.

Filter order, specified as an even positive integer.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Center frequency of the filter, specified as a scalar. When the input sampling frequency `Fs` is specified, the center frequency is in Hz. When the input sample rate is not specified, the center frequency is in normalized units between 0 and 1.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Quality factor of the filter, specified as a real positive scalar.

Quality factor of the filter is defined as the ratio of the center frequency to the 3 dB bandwidth.

`$q={f}_{0}/bw$`

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

3 dB bandwidth of the filter, specified as a real scalar.

Specify the 3 dB bandwidth value in normalized frequency units between 0 and 1. If you specify the sample rate `Fs`, then specify the bandwidth value in Hz instead.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Passband ripple, specified as a positive scalar in dB. If `magunits` is `'linear'` or `'squared'`, the passband ripple is converted and stored in dB by the function regardless of how it has been specified.

Data Types: `double`

Stopband attenuation of the filter, specified as a positive scalar in dB. If `magunits` is `'linear'` or `'squared'`, the stopband attenuation is converted and stored in dB by the function regardless of how it has been specified.

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Sample rate of the signal to be filtered, specified as a scalar in Hz. Specify the sample rate as a scalar trailing the other numerical values provided. When `Fs` is provided, `Fs` is assumed to be in Hz, as are all other frequency values provided. Note that you do not have to change the specification string.

Consider a design specification where N is set to 4, F0 is set to 1200 Hz, and Q is set to 6.5. Specify the sample rate of the input signal as 8000 Hz. Here is how the design looks:

```d = fdesign.notch('N,F0,Q',4,1200,6.5,8e3); filt = design(d,'Systemobject',true);```

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Magnitude specification units, specified as `'dB'`, `'linear'`, or `'squared'`. If this argument is omitted, `'dB'` is assumed. Note that the magnitude specifications are always converted and stored in dB regardless of how they were specified. If `Fs` is one of the input arguments, `magunits` must be specified after `Fs` in the input argument list.

## Output Arguments

collapse all

Notch filter design specification object, returned as a `notch` object. The fields of the object depend on the `spec` input character vector.

Consider an example where the `spec` argument is set to `'N,F0,Q,Ap,Ast'`, and the corresponding values are set to `6`, `0.5`, `10`, `1`, `80`, respectively. The `notch` filter design specification object is populated with the following fields:

### Objects

Introduced in R2011a

Get trial now