Documentation 
Fast Fourier transform (FFT) of input
The FFT block computes the fast Fourier transform (FFT) of each row of a samplebased 1byP input vector, u, or across the first dimension (P) of an ND input array, u. For userspecified FFT lengths, not equal to P, zero padding or truncating, or modulolength data wrapping occurs before the FFT operation, as per Orfanidis [1]:
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
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 moduloM 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 Pad block before the FFT block in your model.
The kth entry of the lth output channel, y(k, l), equals the kth point of the Mpoint discrete Fourier transform (DFT) of the lth input channel:
$$y(k,l)={\displaystyle \sum _{p=1}^{P}u(p,l){e}^{j2\pi (p1)(k1)/M}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}k=1,\dots ,M$$
The block uses one of two possible FFT implementations. You can select an implementation based on the FFTW library [3], [4], or an implementation based on a collection of Radix2 algorithms. You can select Auto to allow the block to choose the implementation.
The FFTW implementation provides an optimized FFT calculation including support for poweroftwo and nonpoweroftwo transform lengths in both simulation and code generation. Generated code using the FFTW implementation will be restricted to those computers which are capable of running MATLAB^{®}. The input data type must be floatingpoint.
The Radix2 implementation supports bitreversed processing, fixed or floatingpoint data, and allows the block to provide portable Ccode generation using the Simulink^{®} Coder™. The dimension M of the MbyN input matrix, must be a power of two. To work with other input sizes, use the Pad block to pad or truncate these dimensions to powers of two, or if possible choose the FFTW implementation.
With Radix2 selected, the block implements one or more of the following algorithms:
Butterfly operation
Doublesignal algorithm
Halflength algorithm
Radix2 decimationintime (DIT) algorithm
Radix2 decimationinfrequency (DIF) algorithm
Complexity of Input  Output Ordering  Algorithms Used for FFT Computation 

Complex  Linear  Bitreversed operation and radix2 DIT 
Complex  Bitreversed  Radix2 DIF 
Real  Linear  Bitreversed operation and radix2 DIT in conjunction with the halflength and doublesignal algorithms 
Real  Bitreversed  Radix2 DIF in conjunction with the halflength and doublesignal algorithms 
The efficiency of the FFT algorithm can be enhanced for real input signals by forming complexvalued sequences from the realvalued sequences prior to the computation of the DFT. When there are 2N+1 real input channels, the FFT block forms these complexvalued sequences by applying the doublesignal algorithm to the first 2N input channels, and the halflength algorithm to the last oddnumbered channel.
For real input signals with fixedpoint data types, it is possible to see different numerical results in the output of the last odd numbered channel, even when all input channels are identical. This numerical difference results from differences in the doublesignal algorithm and the halflength algorithm.
You can eliminate this numerical difference in two ways:
Using full precision arithmetic for fixedpoint input signals
Changing the input data type to floating point
For more information on the doublesignal and halflength algorithms, see Proakis [2]. "Efficient Computation of the DFT of Two Real Sequences" on page 475 describes the double signal algorithm. "Efficient Computation of the DFT of a 2NPoint Real Sequence" on page 476 describes the halflength algorithm.
In certain situations, the block's Radix–2 algorithm computes all the possible trigonometric values of the twiddle factor
$${e}^{j\frac{2\pi k}{K}}$$
where K is the greater value of either M or N and $$k=0,\cdots ,K1$$. The block stores these values in a table and retrieves them during simulation. The number of table entries for fixedpoint and floatingpoint is summarized in the following table:
Number of Table Entries for NPoint FFT  

floatingpoint  3 N/4 
fixedpoint  N 
The following diagrams show the data types used in the FFT block for fixedpoint 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 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. The block multiplies in a twiddle factor before each butterfly stage in a decimationintime FFT and after each butterfly stage in a decimationinfrequency 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 Multiplication Data Types.
The Main pane of the FFT block dialog appears as follows.
Set this parameter to FFTW [3], [4] 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 Radix2 for bitreversed processing, fixed or floatingpoint data, or for portable Ccode generation using the Simulink Coder. The dimension M of the MbyN input matrix, must be a power of two. To work with other input sizes, use the Pad block to pad or truncate these dimensions to powers of two, or if possible choose the FFTW implementation. See Radix2 Implementation.
Set this parameter to Auto to let the block choose the FFT implementation. For nonpoweroftwo 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 bitreversed 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.
Linearly ordering the output requires extra data sorting manipulation, so in some situations it might be better to output in bitreversed order.
Note: The FFT block calculates its output in bitreversed order. Linearly ordering the FFT block output requires an extra bitreversal operation. Thus, in many situations, you can increase the speed of the FFT block by selecting the Output in bitreversed order check box. 
For more information ordering of the output, see Linear and BitReversed Output Order.
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 fixedpoint 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. When you do not select this check box, the FFT length parameter becomes available to specify the length.
Specify FFT length. This parameter becomes available only when you do not select the Inherit FFT length from input dimensions parameter.
When you set the FFT implementation parameter to Radix2, or when you check the Output in bitreversed order check box, this value must be a power of two.
Choose to wrap or truncate the input, depending on the FFT length. If this parameter is checked, modulolength data wrapping occurs before the FFT operation, given FFT length is shorter than the input length. If this property is unchecked, truncation of the input data to the FFT length occurs before the FFT operation. The default is checked.
The Data Types pane of the FFT block dialog appears as follows.
Select the rounding mode for fixedpoint operations. The sine table values do not obey this parameter; instead, they always round to Nearest.
Select the overflow mode for fixedpoint operations. The sine table values do not obey this parameter; instead, they are always saturated.
Choose how you 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)
The sine table values do not obey the Rounding mode and Overflow mode parameters; instead, they are always saturated and rounded to Nearest.
Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Sine table data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
Specify the product output data type. See FixedPoint Data Types and Multiplication Data Types 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
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 data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
Specify the accumulator data type. See FixedPoint Data Types 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
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 data type parameter.
See Specify Data Types Using Data Type Assistant for more information.
Specify the output data type. See FixedPoint Data Types 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 butterfly outputs by two check box.
When you select the Divide butterfly outputs by two check box, the ideal output word and fraction lengths are the same as the input word and fraction lengths.
When you clear the Divide butterfly outputs by two check box, the block computes the ideal output word and fraction lengths according to the following equations:
$$W{L}_{idealoutput}=W{L}_{input}+floor({\mathrm{log}}_{2}(FFTlength1))+1$$
$$F{L}_{idealoutput}=F{L}_{input}$$
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 data type parameter.
See Specify Block Output Data Types for more information.
Select this parameter to prevent the fixedpoint tools from overriding the data types you specify on the block mask.
See the section on Transform TimeDomain Data into Frequency Domain in the DSP System Toolbox™ User's Guide.
[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 (http://www.fftw.org)
[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. 13811384.
Port  Supported Data Types 

Input 

Output 

DCT  DSP System Toolbox 
IFFT  DSP System Toolbox 
Pad  DSP System Toolbox 
fft  MATLAB 
ifft  MATLAB 
bitrevorder  Signal Processing Toolbox 
Simulink Coder  Simulink Coder 