FrequencyDomain FIR Filter
Filter input signal in the frequency domain
Libraries:
DSP System Toolbox /
Filtering /
Filter Implementations
Description
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.
Examples
Ports
Input
x — Data Input
vector  matrix
Data 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 coefficients
row vector
Time domain FIR filter coefficients, specified as a row vector.
Dependencies
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 coefficients
row vector
Frequency 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.
Dependencies
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
Output Arguments
y — Filtered output
vector  matrix
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.
Data Types: single
 double
Complex Number Support: Yes
latency — Filter latency
positive integer
Filter 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
Parameters
Frequencydomain filter method — Filtering method in frequency domain
Overlapsave
(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 domain
Time
(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 coefficients
off (default)  on
When 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.
Dependencies
To enable this parameter, set Numerator domain to
Time
.
Filter coefficients — filter coefficients
fir1(100,0.3)
(default)  row vector
FIR filter coefficients, specified as a row vector.
Dependencies
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 coefficients
off (default)  on
When 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.
Dependencies
To enable this parameter, set Numerator domain to
Frequency
.
Frequency response — Filter coefficients
fft(fir1(100,0.3),202)
(default)  row vector  matrix
Frequency 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.
Dependencies
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 latency
off (default)  on
Flag 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 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.
Dependencies
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 length
101
(default)  positive integervalued scalar
Timedomain numerator length, specified as a positive integervalued scalar.
Dependencies
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 length
on (default)  off
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.
Dependencies
This parameter applies only when you set Numerator
domain to Time
and clear the
Partition numerator to reduce latency
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.
Dependencies
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 real
true
(default)  false
Flag to specify if the filter is real, specified as
true
or false
.
Dependencies
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
button
Opens the Dynamic Filter Visualizer window and displays the magnitude and phase response of the frequency domain FIR filter. The response is based on the parameters you select in the block dialog box. To update the response while the visualizer is running, modify the parameters in the dialog box and click Apply.
You can configure the plot settings and the frequency response measurements from the interface of the visualizer.
On the Plot tab, you can enable the legend, specify to plot both magnitude and phase responses of the filter, modify the plot settings, generate a script to recreate the plot, and even save or share the settings.
On the Measurements tab, you can enable data cursors, and display the peak values of the filter response.
For more details on the Dynamic Filter Visualizer interface and its tools, see Configure Filter Visualizer.
Simulate using — Type of simulation to run
Code generation
(default)  Interpreted execution
Specify the type of simulation to run as one of the following:
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 thanInterpreted execution
.Interpreted execution
–– Simulate model using the MATLAB^{®} interpreter. This option shortens startup time but has slower simulation speed thanCode generation
.
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 

Algorithms
Overlapsave and overlapadd are the two frequencydomain FFTbased filtering methods this algorithm uses.
OverlapSave
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.
OverlapAdd
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.
Reduce Latency Through Impulse Response Partitioning
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].
References
[1] Stockham, T. G., Jr. "High Speed Convolution and Correlation." Proceedings of the 1966 Spring Joint Computer Conference, AFIPS, 28 (1966): 229–233.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2017b
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de 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)