Main Content

FFT

Fast Fourier transform (FFT) of input

  • Library:
  • DSP System Toolbox / Transforms

  • FFT block

Description

TheFFTblock computes the fast Fourier transform (FFT) across the first dimension of anN-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 selectAuto. For more information about the FFT implementations, seeAlgorithms.

For user-specified FFT lengths not equal toP, zero padding or truncating, or modulo-length data wrapping occurs before the FFT operation. For an FFT withPM:

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 theFFTblock uses modulo-Mdata 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 aPadblock before the FFT block in your model.

Ports

Input

expand all

Input signal for computing the FFT. The block computes the FFT along the first dimension of theN-D input signal.

For more information on how the block computes the FFT, seeDescriptionandAlgorithms.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|fixed point
Complex Number Support:Yes

Output

expand all

The FFT, computed across the first dimension of anN-D input array. When the output of the block has an integer or fixed-point data type, it is always signed.

Thekth entry of theLth output channel,y(k,L), equals thekth point of theM-point discrete Fourier transform (DFT) of theLth input channel:

y ( k , L ) = p = 1 P u ( p , L ) e j 2 π ( p 1 ) ( k 1 ) / M k = 1 , , M

For more information on how the block computes the FFT, seeDescriptionandAlgorithms.

Data Types:single|double|int8|int16|int32|fixed point
Complex Number Support:Yes

Parameters

expand all

Main

Set this parameter toFFTWto support an arbitrary length input signal. The block restricts generated code with FFTW implementation to host computers capable of running MATLAB®.

Set this parameter toRadix-2for bit-reversed processing, fixed or floating-point data, or portable C-code generation using the万博1manbetx®Coder™. The dimensionMof theM-by-Ninput matrix, must be a power of two. To work with other input sizes, use thePadblock 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 theRadix-2mode, seeRadix-2 Implementation.

Set this parameter toAutoto 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.

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

TheFFTblock calculates its output in bit-reversed order. Linearly ordering theFFTblock output requires an extra bit-reversal operation. In many situations, you can increase the speed of theFFTblock by selecting theOutput in bit-reversed ordercheck box.

For more information ordering of the output, seeLinear and Bit-Reversed Output Order.

Dependencies

To enable this parameter, setFFT implementationtoAutoorRadix-2.

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.

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, theFFT lengthparameter becomes available to specify the length.

Specify FFT length as an integer greater than or equal to two.

When you set theFFT implementationparameter toRadix-2, or when you check theOutput in bit-reversed ordercheck box, this value must be a power of two.

Dependencies

To enable this parameter, clear theInherit FFT length from input dimensionscheck box.

选择包装或截断输入,根据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 theInherit FFT length from input dimensionscheck box.

Data Types

Select therounding mode为定点操作。

Limitations

The sine table values do not obey this parameter; instead, they always round toNearest.

TheRounding modeparameter has no effect on numeric results when all these conditions are met:

  • Product outputdata type isInherit: Inherit via internal rule.

  • Accumulatordata type isInherit: Inherit via internal rule.

With these data type settings, the block operates in full-precision mode.

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 onsaturateandwrap, seeoverflow mode为定点操作。

Limitations

TheSaturate on integer overflowparameter has no effect on numeric results when all these conditions are met:

  • Product outputdata type isInherit: Inherit via internal rule.

  • Accumulatordata type isInherit: Inherit via internal rule.

With these data type settings, the block operates in full-precision mode.

选择如何指定值的单词长度s 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 theShow data type assistantbuttonto display theData Type Assistant, which helps you set theSine tableparameter.

SeeSpecify Data Types Using Data Type Assistant(Simulink)for more information.

Limitations

The sine table values do not obey theRounding modeandSaturate on integer overflowparameters; instead, they are always saturated and rounded toNearest.

Specify the product output data type. SeeFixed PointandMultiplication Data Typesfor 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, seeInherit via Internal Rule.

  • An expression that evaluates to a valid data type, for example,fixdt(1,16,0)

Click theShow data type assistantbuttonto display theData Type Assistant, which helps you set theProduct outputparameter.

SeeSpecify Data Types Using Data Type Assistant(Simulink)for more information.

Specify the accumulator data type. SeeFixed Pointfor 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, seeInherit via Internal Rule.

  • An expression that evaluates to a valid data type, for example,fixdt(1,16,0)

Click theShow data type assistantbuttonto display theData Type Assistant, which helps you set theAccumulatorparameter.

SeeSpecify Data Types Using Data Type Assistant(Simulink)for more information.

Specify the output data type. SeeFixed Pointfor 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 selectInherit: 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 theDivide output by FFT lengthcheck box.

    • When you select theDivide output by FFT lengthcheck box, the ideal output word and fraction lengths are the same as the input word and fraction lengths.

    • When you clear theDivide output by FFT lengthcheck box, the block computes the ideal output word and fraction lengths according to the following equations:

      W L i d e a l o u t p u t = W L i n p u t + floor ( log 2 ( F F T l e n g t h 1 ) ) + 1

      F L i d e a l o u t p u t = F L i n p u t

    Using these ideal results, the internal rule then selects word lengths and fraction lengths that are appropriate for your hardware. For more information, seeInherit via Internal Rule.

  • An expression that evaluates to a valid data type, for example,fixdt(1,16,0)

Click theShow data type assistantbuttonto display theData Type Assistant, which helps you set theOutputparameter.

SeeControl Data Types of Signals(Simulink)for more information.

Specify the minimum value that the block should output. The default value is[](unspecified). Simulink software uses this value to perform:

  • Simulation range checking (seeSpecify Signal Ranges(Simulink))

  • Automatic scaling of fixed-point data types

Specify the maximum value that the block should output. The default value is[](unspecified). Simulink software uses this value to perform:

  • Simulation range checking (seeSpecify Signal Ranges(Simulink))

  • Automatic scaling of fixed-point data types

Select this parameter to prevent the fixed-point tools from overriding the data types you specify in the block dialog box.

Block Characteristics

Data Types

double|fixed point|integer|single

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

limiteda

Zero-Crossing Detection

no

aVariable-size signals are only supported when the Inherit FFT length from input dimensions checkbox is selected.

Algorithms

expand all

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.

[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

Version History

Introduced before R2006a