filter input signal in the frequency domain -凯发k8网页登录
filter input signal in the frequency domain
libraries:
dsp system toolbox /
filtering /
filter implementations
description
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.
you can specify the filter coefficients directly in the frequency domain by setting
numerator domain to
frequency
.
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 .
examples
ports
input
x — data input
vector | matrix
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.
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 2p-by-n 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 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.
data types: uint32
parameters
frequency-domain filter method — filtering method in frequency domain
overlap-save
(default) | overlap-add
filtering method in the frequency domain, specified as either
overlap-save
or
overlap-add
. for more details on these two
methods, see
numerator domain — numerator domain
time
(default) | frequency
domain of the filter coefficients, specified as one of the following:
time
–– specify the time-domain 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 frequency-domain 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 2p-by-n 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 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 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 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 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
time-domain numerator length — time-domain numerator length
101
(default) | positive integer-valued scalar
time-domain numerator length, specified as a positive integer-valued 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 re-create 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 .
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 |
|
variable-size signals |
|
zero-crossing detection |
|
algorithms
overlap-save and overlap-add are the two frequency-domain fft-based filtering methods this algorithm uses.
overlap-save
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.
overlap-add
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.
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 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 .
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
matlab 命令
您点击的链接对应于以下 matlab 命令:
请在 matlab 命令行窗口中直接输入以执行命令。web 浏览器不支持 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
- (español)
- (english)
- (english)
europe
- (english)
- (english)
- (deutsch)
- (español)
- (english)
- (français)
- (english)
- (italiano)
- (english)
- (english)
- (english)
- (deutsch)
- (english)
- (english)
- switzerland
- (english)
asia pacific
- (english)
- (english)
- (english)
- 中国
- (日本語)
- (한국어)