fast fourier transform (fft) of input -凯发k8网页登录
fast fourier transform (fft) of input
libraries:
dsp system toolbox /
transforms
description
the fft block computes the fast fourier transform (fft) across the first
dimension of an n-d input array, u. the block
uses one of two possible fft implementations. you can select an implementation based on
the fftw library or an implementation based on a collection of radix-2 algorithms. to
allow the block to choose the implementation, you can select
auto
. for more information about the fft implementations,
see algorithms.
for user-specified fft lengths not equal to p, zero padding or truncating, or modulo-length data wrapping occurs before the fft operation. for an fft with p ≤ m:
y = fft(u,m) % p ≤ m
wrapping:
y(:,l) = fft(datawrap(u(:,l),m)) % p > m; l = 1,...,n
truncating:
y (:,l) = fft(u,m) % p > m; l = 1,...,n
tip
when the input length, p, is greater than the fft length, m, you may see magnitude increases in your fft output. these magnitude increases occur because the fft block uses modulo-m data wrapping to preserve all available input samples.
to avoid such magnitude increases, you can truncate the length of your input sample, p, to the fft length, m. to do so, place a block before the fft block in your model.
examples
ports
input
port_1 — input signal
vector | matrix | n-d array
input signal for computing the fft. the block computes the fft along the first dimension of the n-d input signal.
for more information on how the block computes the fft, see description and algorithms.
data types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
complex number support: yes
output
port_1 — fft of input
vector | matrix | n-d array
the fft, computed across the first dimension of an n-d input array. when the output of the block has an integer or fixed-point data type, it is always signed.
the kth entry of the lth output channel, y(k,l), equals the kth point of the m-point discrete fourier transform (dft) of the lth input channel:
for more information on how the block computes the fft, see description and algorithms.
data types: single
| double
| int8
| int16
| int32
| fixed point
complex number support: yes
parameters
main
fft implementation — fft implementation
auto
(default) | radix-2
| fftw
set this parameter to fftw
to support an arbitrary length
input signal. the block restricts generated code with fftw
implementation to host computers capable of running matlab®.
set this parameter to radix-2
for bit-reversed processing,
fixed or floating-point data, or portable c-code generation using the
simulink®
coder™. the dimension m of the
m-by-n input matrix, must be a
power of two. to work with other input sizes, use the block to pad or truncate
these dimensions to powers of two, or if possible choose the fftw
implementation. for more information about the algorithms used by the
radix-2
mode, see radix-2 implementation.
set this parameter to auto
to let the block choose the fft
implementation. for floating-point inputs with non-power-of-two
transform lengths, the fftw algorithm is automatically chosen. otherwise
a radix-2 algorithm is automatically chosen. for non-power-of-two
transform lengths, the block restricts generated code to matlab host computers.
output in bit-reversed order — output in bit-reversed order
off
(default) | on
designate the order of the output channel elements relative to the ordering of the input elements. when you select this check box, the output channel elements appear in bit-reversed order relative to the input ordering. if you clear this check box, the output channel elements appear in linear order relative to the input ordering.
note
the fft block calculates its output in bit-reversed order. linearly ordering the fft block output requires an extra bit-reversal operation. in many situations, you can increase the speed of the fft block by selecting the output in bit-reversed order check box.
for more information ordering of the output, see .
dependencies
to enable this parameter, set fft
implementation to auto
or
radix-2
.
divide output by fft length — divide output by fft length
off
(default) | on
when you select this parameter, the block divides the output of the fft by the fft length. this option is useful when you want the output of the fft to stay in the same amplitude range as its input. this is particularly useful when working with fixed-point data types.
inherit fft length from input dimensions — inherit fft length from input dimensions
on
(default) | off
select to inherit the fft length from the input dimensions. when you select this check box, the input length must be a power of two.
dependencies
when you do not select this check box, the fft length parameter becomes available to specify the length.
fft length — fft length
64
(default) | integer
specify fft length as an integer greater than or equal to two.
when you set the fft implementation parameter to
radix-2
, or when you check the output
in bit-reversed order check box, this value must be a
power of two.
dependencies
to enable this parameter, clear the inherit fft length from input dimensions check box.
wrap input data when fft length is shorter than input length — wrap or truncate input
on
(default) | off
choose to wrap or truncate the input, depending on the fft length. if you select this parameter, modulo-length data wrapping occurs before the fft operation when the fft length is shorter than the input length. if you clear this check box, truncation of the input data to the fft length occurs before the fft operation.
dependencies
to enable this parameter, clear the inherit fft length from input dimensions check box.
data types
rounding mode — rounding method
floor
(default) | ceiling
| convergent
| nearest
| round
| simplest
| zero
select the rounding mode for fixed-point operations.
limitations
the sine table values do not obey this parameter; instead, they
always round to nearest
.
the rounding mode parameter has no effect on numeric results when all these conditions are met:
product output data type is
inherit: inherit via internal rule
.accumulator data type is
inherit: inherit via internal rule
.
with these data type settings, the block operates in full-precision mode.
saturate on integer overflow — saturate on integer overflow
off
(default) | on
when you select this parameter, the block saturates the result of its
fixed-point operation. when you clear this parameter, the block wraps
the result of its fixed-point operation. for details on
saturate
and wrap
, see overflow
mode for fixed-point operations.
limitations
the saturate on integer overflow parameter has no effect on numeric results when all these conditions are met:
product output data type is
inherit: inherit via internal rule
.accumulator data type is
inherit: inherit via internal rule
.
with these data type settings, the block operates in full-precision mode.
sine table — data type of sine table values
inherit: same word length as
input
(default) | fixdt(1,16)
choose how to specify the word length of the values of the sine table. the fraction length of the sine table values always equals the word length minus one. you can set this parameter to:
a rule that inherits a data type, for example,
inherit: same word length as input
an expression that evaluates to a valid data type, for example,
fixdt(1,16)
click the show data type assistant button to display the data type assistant, which helps you set the sine table parameter.
see (simulink) for more information.
limitations
the sine table values do not obey the rounding
mode and saturate on integer
overflow parameters; instead, they are always
saturated and rounded to nearest
.
product output — product output data type
inherit: inherit via internal
rule
(default) | inherit: same as input
| fixdt(1,16,0)
specify the product output data type. see fixed point and for illustrations depicting the use of the product output data type in this block. you can set this parameter to:
a rule that inherits a data type, for example,
inherit: inherit via internal rule
. for more information on this rule, see inherit via internal rule.an expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
click the show data type assistant button to display the data type assistant, which helps you set the product output parameter.
see (simulink) for more information.
accumulator — accumulator data type
inherit: inherit via internal
rule
(default) | inherit: same as input
| inherit: same as product output
| fixdt(1,16,0)
specify the accumulator data type. see fixed point for illustrations depicting the use of the accumulator data type in this block. you can set this parameter to:
a rule that inherits a data type, for example,
inherit: inherit via internal rule
. for more information on this rule, see inherit via internal rule.an expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
click the show data type assistant button to display the data type assistant, which helps you set the accumulator parameter.
see (simulink) for more information.
output — output data type
inherit: inherit via internal
rule
(default) | inherit: same as input
| fixdt(1,16,0)
specify the output data type. see fixed point for illustrations depicting the use of the output data type in this block. you can set this parameter to:
a rule that inherits a data type, for example,
inherit: inherit via internal rule
.when you select
inherit: inherit via internal rule
, the block calculates the output word length and fraction length automatically. the equations that the block uses to calculate the ideal output word length and fraction length depend on the setting of the divide output by fft length check box.when you select the divide output by fft length check box, the ideal output word and fraction lengths are the same as the input word and fraction lengths.
when you clear the divide output by fft length check box, the block computes the ideal output word and fraction lengths according to the following equations:
using these ideal results, the internal rule then selects word lengths and fraction lengths that are appropriate for your hardware. for more information, see inherit via internal rule.
an expression that evaluates to a valid data type, for example,
fixdt(1,16,0)
click the show data type assistant button to display the data type assistant, which helps you set the output parameter.
see (simulink) for more information.
output minimum — minimum value block should output
[]
(default) | scalar
specify the minimum value that the block should output. the default
value is []
(unspecified). simulink software uses this value to perform:
simulation range checking (see (simulink))
automatic scaling of fixed-point data types
output maximum — maximum value block should output
[]
(default) | scalar
specify the maximum value that the block should output. the default
value is []
(unspecified). simulink software uses this value to perform:
simulation range checking (see (simulink))
automatic scaling of fixed-point data types
lock data type settings against changes by the fixed-point tools — prevent fixed-point tools from overriding data types
off
(default) | on
select this parameter to prevent the fixed-point tools from overriding the data types you specify in the block dialog box.
block characteristics
algorithms
fftw implementation
the fftw implementation provides an optimized fft calculation including support for power-of-two and non-power-of-two transform lengths in both simulation and code generation. generated code using the fftw implementation can only run on computers capable of running matlab. the input data type must be floating-point.
radix-2 implementation
the radix-2 implementation supports bit-reversed processing, fixed or floating-point data, and allows the block to provide portable c-code generation using the simulink coder. the dimension m of the m-by-n input matrix must be a power of two. to work with other input sizes, use the block to pad or truncate these dimensions to powers of two, or if possible choose the fftw implementation.
with radix-2 selected, the block implements one or more of the following algorithms:
butterfly operation
double-signal algorithm
half-length algorithm
radix-2 decimation-in-time (dit) algorithm
radix-2 decimation-in-frequency (dif) algorithm
complexity of input | output ordering | algorithms used for fft computation |
---|---|---|
complex | linear | bit-reversed operation and radix-2 dit |
complex | bit-reversed | radix-2 dif |
real | linear | bit-reversed operation and radix-2 dit in conjunction with the half-length and double-signal algorithms |
real | bit-reversed | radix-2 dif in conjunction with the half-length and double-signal algorithms |
the efficiency of the fft algorithm can be enhanced for real input signals by forming complex-valued sequences from the real-valued sequences prior to the computation of the dft. when there are 2n 1 real input channels, the fft block forms these complex-valued sequences by applying the double-signal algorithm to the first 2n input channels, and the half-length algorithm to the last odd-numbered channel.
for real input signals with fixed-point data types, different numerical results might appear in the output of the last odd-numbered channel, even when all input channels are identical. this numerical difference results from differences in the double-signal algorithm and the half-length algorithm.
you can eliminate this numerical difference in two ways:
using full precision arithmetic for fixed-point input signals
changing the input data type to floating point
for more information on the double-signal algorithm, see [2], “efficient computation of the dft of two real sequences” on page 475. for more information on the half-length algorithm, see [2], “efficient computation of the dft of a 2n-point real sequence” on page 476.
in certain situations, the block’s radix–2 algorithm computes all the possible trigonometric values of the twiddle factor
where k is the greater value of either m or n and . the block stores these values in a table and retrieves them during simulation. the number of table entries for fixed-point and floating-point is summarized in the following table:
number of table entries for n-point fft | |
---|---|
floating-point | 3n/4 |
fixed-point | n |
references
[1] orfanidis, s. j. introduction to signal processing. upper saddle river, nj: prentice hall, 1996, p. 497.
[2] proakis, john g. and dimitris g. manolakis. digital signal processing, 3rd ed. upper saddle river, nj: prentice hall, 1996.
[3] fftw ()
[4] frigo, m. and s. g. johnson, “fftw: an adaptive software architecture for the fft,”proceedings of the international conference on acoustics, speech, and signal processing, vol. 3, 1998, pp. 1381-1384.
extended capabilities
c/c code generation
generate c and c code using simulink® coder™.
usage notes and limitations:
when the following conditions apply, the executable generated from this block relies on prebuilt dynamic library files (
.dll
files) included with matlab:fft implementation is set to
fftw
.inherit fft length from input dimensions is cleared, and fft length is set to a value that is not a power of two.
use the
packngo
function to package the code generated from this block and all the relevant files in a compressed zip file. using this zip file, you can relocate, unpack, and rebuild your project in another development environment where matlab is not installed. for more details, see .when the fft length is a power of two, you can generate standalone c and c code from this block.
fixed-point conversion
design and simulate fixed-point systems using fixed-point designer™.
the following diagrams show the data types used in the fft block for fixed-point signals. you can set the sine table, accumulator, product output, and output data types displayed in the diagrams in the fft dialog box as discussed in parameters.
inputs to the fft block are first cast to the output data type and stored in the output buffer. each butterfly stage then processes signals in the accumulator data type, with the final output of the butterfly being cast back into the output data type. the block multiplies in a twiddle factor before each butterfly stage in a decimation-in-time fft and after each butterfly stage in a decimation-in-frequency fft.
the output of the multiplier appears in the accumulator data type because both of the inputs to the multiplier are complex. for details on the complex multiplication performed, see .
note
when the block input is fixed point, all internal data types are signed fixed point.
version history
introduced before r2006a
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)
- 中国
- (日本語)
- (한국어)