Filter input signal in the frequency domain
DSP System Toolbox / Filtering / Filter Implementations
The FrequencyDomain FIR Filter block implements frequencydomain, fast
Fourier transform (FFT)based filtering to filter a streaming input signal. In the time
domain, the filtering operation involves a convolution between the input and the impulse
response of the finite impulse response (FIR) filter. In the frequency domain, the
filtering operation involves the multiplication of the Fourier transform of the input
and the Fourier transform of the impulse response. The frequencydomain filtering
becomes more efficient than timedomain filtering as the impulse response grows longer.
You can specify the filter coefficients directly in the frequency domain by setting
Numerator domain to
Frequency
.
This block uses the overlapsave and overlapadd methods to perform the frequencydomain filtering. For filters with a long impulse response length, the latency inherent to these two methods can be significant. To mitigate this latency, the FrequencyDomain FIR Filter block partitions the impulse response into shorter blocks and implements the overlapsave and overlapadd methods on these shorter blocks. To partition the impulse response, select the Partition numerator to reduce latency check box. For more details on these two methods and on reducing latency through impulse response partitioning, see Algorithms.
x
— Data InputData input, specified as a vector or matrix. This block supports variablesize input signals. That is, you can change the input frame size (number of rows) even after calling the algorithm. However, the number of channels (number of columns) must remain constant.
This port is unnamed until you select the Specify coefficients from input port parameter.
Data Types: single
 double
Complex Number Support: Yes
NUM
— Time domain FIR filter coefficientsTime domain FIR filter coefficients, specified as a row vector.
This port appears when you set Numerator
domain to Time
and select the
Specify coefficients from input port
parameter.
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
Complex Number Support: Yes
NUMFFT
— Frequency domain FIR filter coefficientsFrequency domain FIR filter coefficients, specified as a row vector or a matrix. When you clear the Partition numerator to reduce latency parameter, the coefficients input through this port must be a row vector. The FFT length is equal to the length of the vector input. When you select the Partition numerator to reduce latency parameter, Frequency response must be a 2PbyN matrix, where P is the partition size, and N is the number of partitions.
This port appears when you set Numerator
domain to Frequency
and select the
Specify frequency response from input port
parameter.
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
Complex Number Support: Yes
y
— Filtered outputFiltered output, returned as a vector or matrix. The size, data type, and complexity of the output match those of the input.
This port is unnamed until you select the Output filter latency parameter and click Apply.
Data Types: single
 double
Complex Number Support: Yes
latency
— Filter latencyFilter latency, returned as a scalar. This latency is inherent to overlapadd and overlapsave methods and does not include the group delay of the filter. This port appears only when you select the Output filter latency check box.
This port is unnamed until you select the Output filter latency check box and click Apply.
Data Types: uint32
Frequencydomain filter method
— Filtering method in frequency domainOverlapsave
(default)  Overlapadd
Filtering method in the frequency domain, specified as either
Overlapsave
or
Overlapadd
. For more details on these two
methods, see Algorithms
Numerator domain
— Numerator domainTime
(default)  Frequency
Domain of the filter coefficients, specified as one of the following:
Time
–– Specify the timedomain
filter coefficients in the Filter
coefficients parameter or through the
NUM input port.
Frequency
–– Specify the filter's
frequency response in the Frequency
response parameter or through the
NUMFFT input port.
Specify coefficients from input port
— Flag to specify lowpass filter coefficientsWhen you select this check box, the FIR filter coefficients are input through the port, NUM. When you clear this check box, the coefficients are specified on the block dialog through the Filter coefficients parameter.
To view the filter response, clear this check box, specify the coefficients on the block dialog, and click on the View Filter Response button.
To enable this parameter, set Numerator domain to
Time
.
Filter coefficients
— filter coefficientsfir1(100,0.3)
(default)  row vectorFIR filter coefficients, specified as a row vector.
To enable this parameter, set Numerator domain to
Time
and clear the Specify
coefficients from input port parameter.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
Complex Number Support: Yes
Specify frequency response from input port
— Flag to specify frequencydomain filter coefficientsWhen you select this check box, the FIR filter coefficients in the frequency domain are input through the port, NUMFFT. When you clear this check box, the coefficients are specified on the block dialog through the Frequency response parameter.
To view the filter response, clear this check box, specify the frequency response on the block dialog, and click on the View Filter Response button.
To enable this parameter, set Numerator domain to
Frequency
.
Frequency response
— Filter coefficientsfft(fir1(100,0.3),202)
(default)  row vector  matrixFrequency response of the filter, specified as a row vector or a matrix. When you clear the Partition numerator to reduce latency parameter, Frequency response must be a row vector. The FFT length is equal to the length of the Frequency response vector. When you select the Partition numerator to reduce latency parameter, Frequency response must be a 2PbyN matrix, where P is the partition size, and N is the number of partitions.
To enable this parameter, set Numerator domain to
Frequency
and clear the Specify
frequency response from input port parameter.
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
Complex Number Support: Yes
Partition numerator to reduce latency
— Flag to partition the numerator to reduce latencyFlag to partition the numerator to reduce latency, specified as one of the following:
off –– The filter uses the traditional overlapsave or overlapadd method. The latency in this case is FFT length – NumLen + 1. NumLen is the length of the numerator vector you specify in the Filter coefficients parameter.
on –– In this mode, the block partitions the numerator into segments of length specified by the Numerator partition length parameter. The filter performs overlapsave or overlapadd on each partition, and combines the partial results to form the overall output. The latency is now reduced to the partition length.
Numerator partition length
— Partition length of numerator32
(default)  positive integerPartition length of the numerator, specified as a positive integer less than or equal to the length of the numerator.
This parameter applies only when you set Numerator
domain to Time
and select the
Partition numerator to reduce latency
parameter.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
Timedomain numerator length
— Timedomain numerator length101
(default)  positive integervalued scalarTimedomain numerator length, specified as a positive integervalued scalar.
This parameter applies only when you set Numerator
domain to Frequency
and clear
the Partition numerator to reduce latency check
box.
Data Types: single
 double
 int8
 int16
 int32
 uint8
 uint16
 uint32
Inherit FFT length from numerator length
— Flag to inherit FFT length from the numerator lengthWhen you select this check box, the FFT length equals twice the numerator length. When you clear this check box, you specify the FFT length through the FFT length parameter.
This parameter applies only when you set Numerator
domain to Time
and clear the
Partition numerator to reduce latency
parameter.
FFT length
— FFT length1024
(default)  positive integerThe FFT length you specify must be greater than or equal to the length of the numerator vector you specify in the Filter coefficients parameter.
This parameter applies when you set Numerator
domain to Time
, clear the
Partition numerator to reduce latency and the
Inherit FFT length from numerator length
parameters.
Data Types: single
 double
 int8
 int16
 int32
 int64
 uint8
 uint16
 uint32
 uint64
Filter is real
— Flag to specify if filter is realtrue
(default)  false
Flag to specify if the filter is real, specified as
true
or false
.
This parameter applies when Numerator domain to
Frequency
.
Output filter latency
— Flag to output filter latency'off'
(default)  'on'
When you select this check box and click Apply, the block outputs the filter latency through the latency port.
View Filter Response
— Visualize frequency response of FIR filterbutton
Opens the Filter Visualization Tool (FVTool) and displays the magnitude/phase response of the FIR filter. The response is based on the block dialog parameters. Changes made to these parameters update FVTool.
To update the magnitude response while FVTool is running, modify the block dialog parameters and click Apply.
To view the filter response when the Numerator domain
is set to Time
, clear the Specify
coefficients from input port check box. To view the filter
response when the Numerator domain is set to
Frequency
, clear the Specify
frequency response from input port check box.
Simulate using
— Type of simulation to runCode generation
(default)  Interpreted execution
Code generation
— Simulate model
using generated C code. The first time you run a simulation,
Simulink^{®} generates C code for the block. The C code is reused
for subsequent simulations, as long as the model does not change.
This option requires additional startup time but provides faster
simulation speed than Interpreted
execution
.
Interpreted execution
— Simulate
model using the MATLAB^{®} interpreter. This option shortens startup time
but has slower simulation speed than Code
generation
.
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

Overlapsave and overlapadd are the two frequencydomain FFTbased filtering methods this algorithm uses.
The overlapsave method is implemented using the following approach:
The input stream is partitioned into overlapping blocks of size FFTLen, with an overlap factor of NumLen – 1 samples. FFTLen is the FFT length and NumLen is the length of the FIR filter numerator. The FFT of each block of input samples is computed and multiplied with the lengthFFTLen FFT of the FIR numerator. The inverse fast Fourier transform (IFFT) of the result is performed, and the last FFTLen – NumLen + 1 samples are saved. The remaining samples are dropped.
The latency of overlapsave is FFTLen – NumLen + 1. The first FFTLen – NumLen + 1 samples are equal to zero. The filtered value of the first input sample appears as the FFTLen – NumLen + 2 output sample.
Note that the FFT length must be larger than the numerator length, and is typically set to a value much greater than NumLen.
The overlapadd method is implemented using the following approach:
The input stream is partitioned into blocks of length FFLen – NumLen + 1, with no overlap between consecutive blocks. Similar to overlapsave, the FFT of the block is computed, and multiplied by the FFT of the FIR numerator. The IFFT of the result is then computed. The first NumLen + 1 samples are modified by adding the values of the last NumLen + 1 samples from the previous computed IFFT.
The latency of overlapadd is FFTLen – NumLen + 1. The first FFTLen – NumLen + 1 samples are equal to zero. The filtered value of the first input sample appears as the FFTLen – NumLen + 2 output sample.
With an FFT length that is twice the length of the FIR numerator, the latency roughly equals the length of the FIR numerator. If the impulse response is very long, the latency becomes significantly large. However, frequency domain FIR filtering is still faster than the timedomain filtering. To mitigate the latency and make the frequency domain filtering even more efficient, the algorithm partitions the impulse response into multiple short blocks and performs overlapsave or overlapadd on each block. The results of the different blocks are then combined to obtain the final output. The latency of this approach is of the order of the block length, rather than the entire impulse response length. This reduced latency comes at the cost of additional computation. For more details, see [1].
[1] Stockham, T. G., Jr. "High Speed Convolution and Correlation." Proceedings of the 1966 Spring Joint Computer Conference, AFIPS, 28 (1966): 229–233.
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.
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: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.