| DSP Blockset | ![]() |
Library
Description![]()
The FFT block computes the fast Fourier transform (FFT) of each channel of an M-by-N or length-M input, u, where M must be a power of two. To work with other input sizes, use the Zero Pad block to pad or truncate the length-M dimension to a power-of-two length.
The output of the FFT block is equivalent to the MATLAB fft function:
The kth entry of the lth output channel, y(k, l), is equal to the kth point of the M-point discrete Fourier transform (DFT) of the lth input channel:
This block supports real and complex floating-point and fixed-point inputs.
Sections of This Reference Page
For information on block output characteristics and how to configure the block computation methods, see other sections of this reference page:
Input and Output Characteristics
The following table describes valid inputs to the FFT block, their corresponding outputs, and the dimension along which the block computes the DFT.
| Valid Block Inputs |
Dimension Along Which Block Computes DFT |
Corresponding Block Output Characteristics Output port rate = input port rate |
| Frame-based M-by-N matrix |
Column |
|
Sample-based M-by-N matrix, ![]() |
Column |
|
| Sample-based 1-by-M row vector |
Row |
|
| Unoriented length-M 1-D vector |
Vector |
Unoriented, length-M, complex-valued 1-D vector containing M-point DFT of input in linear or bit-reversed order |
The following diagram shows the effects of the input size, dimension, and frame status on the output of the FFT block (see also fft_ins_outs.mdl).

Selecting the Twiddle Factor Computation Method
The Twiddle factor computation parameter determines how the block computes the necessary sine and cosine terms to calculate the term
, shown in the first equation of this block reference page. This parameter has two settings, each with its advantages and disadvantages, as described in the following table. Note that only Table lookup mode is supported for fixed-point signals.
| Twiddle Factor Computation Parameter Setting |
Sine and Cosine Computation Method |
Effect on Block Performance |
Table lookup |
The block computes and stores the trigonometric values before the simulation starts, and retrieves them during the simulation. When you generate code from the block, the processor running the generated code stores the trigonometric values computed by the block, and retrieves the values during code execution. |
The block usually runs much more quickly, but requires extra memory for storing the precomputed trigonometric values. You can optimize the table for memory consumption or speed, as described in Optimizing the Table of Trigonometric Values below. |
Trigonometric fcn |
The block computes sine and cosine values during the simulation. When you generate code from the block, the processor running the generated code computes the sine and cosine values while the code runs. |
The block usually runs more slowly, but does not need extra data memory. For code generation, the block requires a support library to emulate the trigonometric functions, increasing the size of the generated code. |
Optimizing the Table of Trigonometric Values
When you set the Twiddle factor computation parameter to Table lookup, you need to also set the Optimize table for parameter. This parameter optimizes the table of trigonometric values for speed or memory by varying the number of table entries as summarized in the following table.
Ordering Output Column Entries
You can set the Output in bit-reversed order parameter to specify the ordering of the column elements of the output as either linear or bit-reversed.
Two numbers are bit-reversed values of each other when the binary representation of one is the mirror image of the binary representation of the other. For example, in a three-bit system, one and four are bit-reversed values of each other, since the three-bit binary representation of one, 001, is the mirror image of the three-bit binary representation of four, 100.
In the diagram below, the sequence 0, 1, 2, 3, 4, 5, 6, 7 is in linear order. To put the sequence in bit-reversed order, replace each element in the linearly ordered sequence with its bit-reversed counterpart. You can do this by translating the sequence into its binary representation with the minimum number of bits, then finding the mirror image of each binary entry, and finally translating the sequence back to its decimal representation. The resulting sequence is the original linearly ordered sequence in bit-reversed order.
Set the Output in bit-reversed order parameter as follows to indicate the ordering of the output's column elements.
| Note Linearly ordering the output requires extra data sorting manipulation, so in some situations it may be better to output in bit-reversed order as illustrated in the example, The Use of Bit-Reversed Outputs. |
The next diagram illustrates the difference between linear and bit-reversed outputs. Note that output values in linear and bit-reversed order are the same; only the order in which they appear in the columns differs.

Algorithms Used for FFT Computation
Depending on whether the block input is floating-point or fixed-point, real- or complex-valued, and whether you want the output in linear or bit-reversed order, the block uses one or more of the following algorithms as summarized in the following tables:
| Complexity of Input |
Output Ordering |
Algorithms Used for FFT Computation |
| Real or complex |
Linear |
Radix-2 DIT |
| Real or complex |
Bit-reversed |
Radix-2 DIF |
Fixed-Point Data Types
The diagrams below show the data types used within 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 block mask as discussed in Dialog Box.
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. A twiddle factor is multiplied in 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 is in the accumulator data type since both of the inputs to the multiplier are complex. For details on the complex multiplication performed, refer to Multiplication Data Types.
The Use of Bit-Reversed Outputs
The FFT block runs more quickly when it outputs in bit-reversed order. You can often use an output in bit-reversed order when your model also uses the IFFT block, which allows you to indicate whether its input is in bit-reversed or linear order.
For instance, set the FFT block to output in bit-reversed order when you want to filter or convolve signals by taking the FFT of time domain data, multiplying frequency-domain data, and inputting the product to an IFFT block that is configured to accept input in bit-reversed order.
The following model shows the implementation of the Overlap-Save FFT Filter block. The implementation uses the FFT block in conjunction with an IFFT block, so the FFT block is set to output in bit-reversed order, and the IFFT block is set to accept inputs in bit-reversed order. Note that the implementation uses the bitrevorder function to put the vector H into bit-reversed order before multiplying it with the bit-reversed FFT outputs:
Look under mask.
Dialog Box
, shown in the first equation of this block reference page. In Table lookup mode, the block computes and stores the sine and cosine values before the simulation starts. In Trigonometric fcn mode, the block computes the sine and cosine values during the simulation. See Selecting the Twiddle Factor Computation Method.
Table lookup for fixed-point signals.
Speed or Memory. This parameter is only available when the Twiddle factor computation parameter is set to Table lookup. See Selecting the Twiddle Factor Computation Method.
Speed for fixed-point signals.
Same as input, the word and fraction lengths of the sine table values are the same as those of the input of the block. If you select Same as output, they are the same as those of the output of the block. If you select User-defined, the Fixed-point sine table word length and Fixed-point sine table fraction length parameters become visible.
Nearest.
User-defined is specified for the Fixed-point sine table attributes parameter.
User-defined is specified for the Fixed-point sine table attributes parameter.
Same as input, these characteristics will match those of the input to the block. If you select User-defined, the Output word length and Output fraction length parameters become visible.
User-defined is specified for the Fixed-point output attributes parameter.
User-defined is specified for the Fixed-point output attributes parameter.
Same as input, the accumulator word and fraction lengths are the same as those of the input to the block. If you select Same as output, they are the same as those of the output of the block. If you select User-defined, the Accumulator word length and Accumulator fraction length parameters become visible.
User-defined is specified for the Fixed-point accumulator attributes parameter.
User-defined is specified for the Fixed-point accumulator attributes parameter.
Same as input, Same as output, or Same as accumulator, the product output word and fraction lengths are the same as those of the input, output, or accumulator of the block, respectively. If you select User-defined, the Product output word length and Product output fraction length parameters become visible.
User-defined is specified for the Fixed-point product output attributes parameter.
User-defined is specified for the Fixed-point product output attributes parameter.
Nearest.
Supported Data Types
To learn how to convert your data types to the above data types in MATLAB and Simulink, see Supported Data Types and How to Convert to Them.
See Also
| Complex Cepstrum |
DSP Blockset |
| DCT |
DSP Blockset |
| IFFT |
DSP Blockset |
| Pad |
DSP Blockset |
| Zero Pad |
DSP Blockset |
bitrevorder |
Signal Processing Toolbox |
fft |
Signal Processing Toolbox |
ifft |
Signal Processing Toolbox |
| Fast Block LMS Filter | Filter Realization Wizard | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |