dsp.Differentiator
Direct form FIR fullband differentiator filter
Description
The dsp.Differentiator
System object™ applies a fullband differentiator filter on the input signal to differentiate
all its frequency components. This object uses an FIR equiripple filter design to design the
differentiator filter. The ideal frequency response of the differentiator is for . You can design the filter with minimum order with a specified order. This
object supports fixed-point operations.
To filter each channel of your input:
Create the
dsp.Differentiator
object and set its properties.Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?
Creation
Description
returns a
differentiator, DF
= dsp.DifferentiatorDF
, which independently filters each channel of the
input over time using the given design specifications.
sets each property name to the specified value. Unspecified properties have default
values.DF
= dsp.Differentiator(Name,Value
)
Properties
Unless otherwise indicated, properties are nontunable, which means you cannot change their
values after calling the object. Objects lock when you call them, and the
release
function unlocks them.
If a property is tunable, you can change its value at any time.
For more information on changing property values, see System Design in MATLAB Using System Objects.
DesignForMinimumOrder
— Design minimum order filter
true
(default) | false
Option to design a minimum-order filter, specified as a logical scalar. The filter has 2 degrees of freedom. When you set this property to
true
— The object designs the filter with the minimum order that meets thePassbandRipple
value.false
— The object designs the filter with order that you specify in theFilterOrder
property.
This property is not tunable.
FilterOrder
— Order of the filter
31 (default) | odd positive integer
Order of the filter, specified as an odd positive integer.
This property is not tunable.
Dependencies
You can specify the filter order only when
'DesignForMinimumOrder'
is set to
false
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
PassbandRipple
— Maximum passband ripple
0.1 (default) | positive real scalar
Maximum passband ripple in dB, specified as a positive real scalar.
This property is not tunable.
Dependencies
You can specify the passband ripple only when
'DesignForMinimumOrder'
is set to true
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
ScaleCoefficients
— Scale filter coefficients
false
(default) | true
Option to scale the filter coefficients, specified as a logical scalar. When you set
this property to true
, the object scales the filter coefficients to
preserve the input dynamic range.
This property is not tunable.
Fixed-Point Properties
CoefficientsDataType
— Word and fraction lengths of coefficients
numerictype(1,16)
(default) | numerictype
object
Word and fraction lengths of coefficients, specified as a signed or unsigned
numerictype
object. The default,
numerictype(1,16)
, corresponds to a signed numeric type object
with 16-bit coefficients. To give the best possible precision, the fraction length is
computed based on the coefficient values.
This property is not tunable.
The word length of the output is the same as the word length of the input. The object computes the fraction length of the output such that the entire dynamic range of the output can be represented without overflow. For details on how the object computes the fraction length of the output, see Fixed-Point Precision Rules for Avoiding Overflow in FIR Filters.
RoundingMethod
— Rounding method for output fixed-point operations
'Floor'
(default) | 'Ceiling'
| 'Convergent'
| 'Nearest'
| 'Round'
| 'Simplest'
| 'Zero'
Rounding method for output fixed-point operations, specified as a character vector. For more information on the rounding modes, see Precision and Range.
This property is not tunable.
Usage
Syntax
Description
Input Arguments
x
— Data input
vector | matrix
Data input, specified as a vector or a matrix. If the input signal is a matrix, each column of the matrix is treated as an independent channel. The number of rows in the input signal denotes the channel length. The data type characteristics (double, single, or fixed-point) and the real-complex characteristics (real or complex valued) must be the same for the input data and output data.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Output Arguments
y
— Differentiated signal
vector | matrix
Differentiated signal, returned as a vector or matrix of the same size, data type,
and complexity as the input signal, x
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Complex Number Support: Yes
Object Functions
To use an object function, specify the
System object as the first input argument. For
example, to release system resources of a System object named obj
, use
this syntax:
release(obj)
Examples
Group Delay Estimation
Estimate the group delay of a linear phase FIR filter using a dsp.TransferFunctionEstimator
object followed by dsp.PhaseExtractor
and dsp.Differentiator
objects. The group delay of a linear phase FIR filter is given by , where
is the phase information of the filter,
is the frequency vector, and N is the order of the filter.
Set Up the Objects
Create a linear phase FIR lowpass filter. Set the order to 200, the passband frequency to 255 Hz, the passband ripple to 0.1 dB, and the stopband attenuation to 80 dB. Specify a sample rate of 512 Hz.
Fs = 512; LPF = dsp.LowpassFilter('SampleRate',Fs,'PassbandFrequency',255,... 'DesignForMinimumOrder',false,'FilterOrder',200);
To estimate the transfer function of the lowpass filter, create a transfer function estimator. Specify the window to be Hann
. Set the FFT length to 1024 and the number of spectral averages to 200.
TFE = dsp.TransferFunctionEstimator('FrequencyRange','twosided',... 'SpectralAverages',200,'FFTLengthSource','Property',... 'FFTLength',1024);
To extract the unwrapped phase from the frequency response of the filter, create a phase extractor.
PE = dsp.PhaseExtractor;
To differentiate the phase , create a differentiator filter. This value is used in computing the group delay.
DF = dsp.Differentiator;
To smoothen the input, create a variable bandwidth FIR filter.
Gain1 = 512/pi; Gain2 = -1; VBFilter = dsp.VariableBandwidthFIRFilter('CutoffFrequency',10,... 'SampleRate',Fs);
To view the group delay of the filter, create an array plot object.
AP = dsp.ArrayPlot('PlotType','Line','YLimits',[-500 400],... 'YLabel','Amplitude','XLabel','Number of samples');
Run the Algorithm
The for
-loop is the streaming loop that estimates the group delay of the filter. In the loop, the algorithm filters the input signal, estimates the transfer function of the filter, and differentiates the phase of the filter to compute the group delay.
Niter = 1000; % Number of iterations for k = 1:Niter x = randn(512,1); % Input signal = white Gaussian noise y = LPF(x); % Filter noise with Lowpass FIR filter H = TFE(x,y); % Compute transfer function estimate Phase = PE(H); % Extract the Unwrapped phase phaseaftergain1 = Gain1*Phase; DiffOut = DF(phaseaftergain1); % Differentiate the phase phaseaftergain2 = Gain2 * DiffOut; VBFOut = VBFilter(phaseaftergain2); % Smooth the group delay AP(VBFOut); % Display the group delay end
As you can see, the group delay of the lowpass filter is 100.
Convert FM Signal to AM Signal
Create an FM wave on a 100 Hz carrier signal sampled at 1.5 kHz.
Fc = 1e2; % Carrier Fs = 1.5e3; % Sample rate sinewave = dsp.SineWave('Frequency',10,... 'SamplesPerFrame',1e3,... 'SampleRate',Fs);
Convert the FM signal to an AM signal.
ts = timescope('TimeSpanSource','Property',... 'TimeSpan',0.3,... 'BufferLength',10*Fs,... 'SampleRate',Fs,... 'ShowGrid',true,... 'YLimits',[-1.5 1.5],... 'LayoutDimensions',[2 1]); df = dsp.Differentiator; tic while toc<2.2 x = step(sinewave); fm_y = modulate(x,Fc,Fs,'fm'); am_y = step(df,fm_y); step(ts,fm_y,am_y); end release(df); release(ts);
Algorithms
Differentiator Filter
Differentiator computes the derivative of a signal. The frequency response of an ideal differentiator filter is given by , defined over the Nyquist interval .
The frequency response is antisymmetric and is linearly proportional to the frequency.
dsp.Differentiator
object acts as a differentiator
filter. This object condenses the two-step process into one. For the
minimum order design, the object uses generalized Remez FIR filter
design algorithm. For the specified order design, the object uses
the Parks-McClellan optimal equiripple FIR filter design algorithm.
The filter is designed as a linear phase Type-IV FIR filter with a
Direct form structure.
The ideal differentiator has an antisymmetric impulse response given by . Hence . The differentiator must have zero response at zero frequency.
Linear-Phase FIR Differentiator Filter
The impulse response of an antisymmetric linear-phase FIR filter is given by , where M is the length of the filter. Because the filter is antisymmetric, you can use this type of FIR filter to design the linear-phase FIR differentiators.
Consider the design of linear-phase FIR differentiators based on the Chebyshev approximation criterion.
If M is odd, the real-valued frequency response of the FIR filter, Hr(ω), has the characteristics that Hr(0) = 0 and Hr(π) = 0. This filter satisfies the condition of zero response at zero frequency. However, it is not fullband because Hr(π) = 0. This differentiator has a linear response over the limited frequency range [0 2πfp], where fp is the bandwidth of the differentiator. The absolute error between the desired response and the Chebyshev approximation increases as ω increases from 0 to 2πfp.
If M is even, the real-valued frequency response of the FIR filter, Hr(ω), has the characteristics that Hr(0) = 0 and Hr(π) ≠ 0. This filter satisfies the condition of zero response at zero frequency. It is fullband and this design results in a significantly smaller approximation error than comparable odd-length differentiators. Hence, even-length (odd order) differentiators are preferred in practical systems.
References
[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1996.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).
This object also supports SIMD code generation using Intel AVX2 technology when the
input signal has a data type of single
or
double
.
The SIMD technology significantly improves the performance of the generated code.
Version History
Introduced in R2016a
See Also
Functions
Objects
dsp.HighpassFilter
|dsp.VariableBandwidthFIRFilter
|dsp.VariableBandwidthIIRFilter
|dsp.FIRFilter
|dsp.SOSFilter
Blocks
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)