Differentiator FIR
Design differentiator finite impulse response filter
Description
A differentiator filter computes the time derivative of an input signal by applying the properties of the Fourier transform. A finite impulse response (FIR) filter computes an output signal as a running weighted average of input samples.
Signal Processing Toolbox™ provides different ways to design differentiator FIR filters:
designfiltfunction — Design a differentiator FIR filter at the command line or in a script. Use"differentiatorfir"as the first argument when you call the function.For an example, see Design Differentiator FIR Filter Using designfilt.
Design Filter Live Editor task — Design a differentiator FIR filter as part of a live script. The task displays code that you can paste into other MATLAB® programs.
For an example, see Design Differentiator FIR Filter Using Live Editor Task.
Filter Designer app — Design a differentiator FIR filter interactively. Export your design to the MATLAB workspace or to a file.
For an example, see Design Differentiator FIR Filter Using Filter Designer.
All of these methods return digitalFilter objects. If you
have a DSP System Toolbox™ license, you can generate your design as a filter System object™ and include additional Design Method Options.
For other ways to design differentiator FIR filters using MATLAB, see Other Differentiator FIR Filter Design Functions.
Examples
To design the filter at the command line or in a script, use the designfilt function with "differentiatorfir" as the first argument. Use name-value arguments to specify your design further.
d = designfilt("differentiatorfir", ... % Response type SampleRate=2000, ... % Sample rate FilterOrder=42, ... % Filter order PassbandFrequency=400, ... % Frequency constraints StopbandFrequency=550, ... DesignMethod="ls"); % Design method filterAnalyzer(d)

To design the filter using the Design Filter Live Editor task:
Specify the filter:
Under Select filter response, select Differentiator FIR.
Under Sample Rate, specify Frequency units as
Hzand Input sample rate (Hz) as2000.Under Specify filter order, specify Order Mode as
Specifyand Order as42.Under Specify frequency parameters, specify a passband frequency of
400Hz and a stopband frequency of550Hz.Under Specify algorithm, select
FIR least-squares.
The Live Editor task updates the filter automatically by default.

To design the filter using the Filter Designer app:
In the Response gallery of the Designer tab in the app toolstrip, select Differentiator FIR.
Specify the filter using the options in the Filter Parameters table:
Under Sample Rate, specify Frequency units as
Hzand Input sample rate (Hz) as2000.Under Filter Order, specify Order Mode as
Specifyand Order as42.Under Frequency Specifications, specify a passband frequency of
400Hz and a stopband frequency of550Hz.Under Algorithm, select
FIR least-squares.
In the Filter section of the Designer tab, click Update Filter.

Export code to create your digital filter. On the toolstrip, click Export and select
Generate MATLAB function>Digital Filter Object. The code appears in the editor.function designedFilter = differentiatorfir1filt designedFilter = designfilt('differentiatorfir', ... 'FilterOrder',42,'PassbandFrequency',400, ... 'StopbandFrequency',550,'SampleRate',2000, ... 'DesignMethod','ls'); end
Parameters
Design Method
Specify the algorithm to design the filter. The available design methods correlate with the set of design specifications that you choose.
Design the filter using the Parks-McClellan algorithm. Equiripple filters have a frequency response that minimizes the maximum ripple magnitude over all bands.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
Specify
| In the Specify algorithm section of the
task, set Design method to
| In the Algorithm section of the filter
parameters panel, set Design method to
|
The equiripple design method supports these design parameter combinations.
| Filter Order | Frequency Specifications | Magnitude Specifications | Design Method Options | DSP System Toolbox License Required |
|---|---|---|---|---|
| N/A | N/A | N/A | |
|
| N/A |
| |
| N/A |
|
|
| ✓ |
Design the filter using the least-squares algorithm. The method minimizes the discrepancy between a specified arbitrary piecewise-linear function and the filter’s magnitude response.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
Specify | In the Specify algorithm section of the
task, set Design method to | In the Algorithm section of the filter
parameters panel, set Design method to
|
The least-squares design method supports these design parameter combinations.
| Filter Order | Frequency Specifications | Magnitude Specifications | Design Method Options | DSP System Toolbox License Required |
|---|---|---|---|---|
| N/A | N/A | N/A | |
|
| N/A | N/A |
Sample Rate
Specify the filter sample rate as a positive scalar expressed in hertz.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
| In the Sample Rate section of the task:
| In the Sample Rate section of the filter parameters panel:
|
Filter Order
Specify the filter order N as a positive integer. Some design methods let you specify the order. Others generate minimum-order designs, which are the shortest filters that satisfy the specified constraints.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
| In the Specify Filter Order section of the task:
| In the Filter Order section of the filter parameters panel:
|
Frequency Specifications
Specify the passband frequency as a positive scalar smaller than the Nyquist frequency. If you work with normalized frequencies, the Nyquist frequency is 1. If you specify a sample rate Fs, the Nyquist frequency is Fs/2.
The passband frequency is the highest frequency for which the magnitude response of the filter is within an interval of width Passband Ripple from the reference value, usually 0 dB.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
|
|
|
Specify the stopband frequency as a positive scalar smaller than the Nyquist frequency. If you work with normalized frequencies, the Nyquist frequency is 1. If you specify a sample rate Fs, the Nyquist frequency is Fs/2.
The stopband frequency is the lowest frequency for which the magnitude response of the filter is at least Stopband Attenuation dB lower than the reference value, usually 0 dB.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
|
|
|
Magnitude Specifications
Specify the passband ripple as a positive scalar in decibels.
The passband ripple measures the fluctuation of the passband gain of the filter about the reference value, usually 0 dB.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
|
|
|
Specify the stopband attenuation as a positive scalar in decibels.
The stopband attenuation measures the extent by which the filter gain in the stopband is decreased in comparison to the reference value, usually 0 dB.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
|
|
|
Design Method Options
Basic Options
Passband optimization weight, specified as a positive scalar.
Weights are a way of specifying the relative importance of the passband ripple and the stopband attenuation in a filter design. By default, the passband and the stopband are equally weighted, each with unit weight. By increasing the passband weight, you can increase the passband ripple at the expense of increasing the stopband attenuation.
You must have a DSP System Toolbox license to use this option with some syntaxes.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
|
|
|
Stopband optimization weight, specified as a positive scalar.
Weights are a way of specifying the relative importance of the passband ripple and the stopband attenuation in a filter design. By default, the passband and the stopband are equally weighted, each with unit weight. By increasing the stopband weight, you can increase the stopband attenuation at the expense of increasing the passband ripple.
You must have a DSP System Toolbox license to use this option with some syntaxes.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
|
|
|
Advanced Options
Density of the frequency grid used by the Equiripple algorithm, specified as a positive scalar ≥ 10. The frequency grid has roughly (Density Factor × Filter Order)/(2 × Passband Frequency) frequency points. Increasing the density factor results in filters that more closely approximate an equiripple filter but take longer to compute.
You must have a DSP System Toolbox license to use this option. This parameter is available only in the
designfilt function.
designfilt Function | Design Filter Live Editor Task | Filter Designer App |
|---|---|---|
| N/A | N/A |
More About
See Also
Apps
Functions
Live Editor Tasks
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)