Filter input signal in the frequency domain
DSP System Toolbox / Filtering / Filter Implementations
The Frequency-Domain FIR Filter block implements frequency-domain, 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 frequency-domain filtering becomes more efficient than time-domain filtering as the impulse response grows longer. This block uses the overlap-save and overlap-add methods to perform the frequency-domain filtering. For filters with a long impulse response length, the latency inherent to these two methods can be significant. To mitigate this latency, the Frequency-Domain FIR Filter block partitions the impulse response into shorter blocks and implements the overlap-save and overlap-add 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.
Port_1— Data Input
Data input, specified as a vector or matrix. This block supports variable-size 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.
Complex Number Support: Yes
y— Filtered output
Filtered 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.
Complex Number Support: Yes
latency— Filter latency
Filter latency, returned as a scalar. This latency is inherent to overlap-add and overlap-save 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.
Frequency-domain filter method— Filtering method in frequency domain
Filtering method in the frequency domain, specified as either
Overlap-add. For more details on these two
methods, see Algorithms
Filter coefficients— filter coefficients
fir1(100,0.3)(default) | row vector
FIR filter coefficients, specified as a row vector.
Complex Number Support: Yes
Partition numerator to reduce latency— Flag to partition the numerator to reduce latency
Flag to partition the numerator to reduce latency, specified as one of the following:
'off' –– The filter uses the traditional
overlap-save or overlap-add method. The latency in this case is
FFT length – NumLen + 1.
NumLen is the length of the numerator
vector you specify in the Filter
'on' –– In this mode, the block partitions
the numerator into segments of length specified by the
Numerator partition length parameter.
The filter performs overlap-save or overlap-add on each
partition, and combines the partial results to form the overall
output. The latency is now reduced to the partition
Numerator partition length— Partition length of numerator
32(default) | positive integer
Partition 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 select the Partition numerator to reduce latency check box.
Inherit FFT length from numerator length— Flag to inherit FFT length from the numerator length
When 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.
FFT length— FFT length
1024(default) | positive integer
The 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 clear the Inherit FFT length from numerator length check box.
Output filter latency— Flag to output filter latency
When you select this check box and click Apply, the block outputs the filter latency through the latency port.
View Filter Response— Visualize the frequency response of the FIR filter
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.
Simulate using— Type of simulation to run
Code generation(default) |
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 — Simulate
model using the MATLAB® interpreter. This option shortens startup time
but has slower simulation speed than
Overlap-save and overlap-add are the two frequency-domain FFT-based filtering methods this algorithm uses.
The overlap-save 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 length-FFTLen 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 overlap-save 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 overlap-add 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 overlap-save, 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 overlap-add 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 filterting is still faster than the time-domain 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 overlap-save or overlap-add 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 .
 Stockham, T. G., Jr. "High Speed Convolution and Correlation." Proceedings of the 1966 Spring Joint Computer Conference, AFIPS, Vol 28, 1966, pp. 229–233.