fftn - N-D fast Fourier transform - MATLAB (original) (raw)
N-D fast Fourier transform
Syntax
Description
Y = fftn([X](#bvhcsbe-1-X))
returns the multidimensional Fourier transform of an N-D array using a fast Fourier transform algorithm. The N-D transform is equivalent to computing the 1-D transform along each dimension of X
. The output Y
is the same size as X
.
Y = fftn([X](#bvhcsbe-1-X),[sz](#bvhcsbe-1-sz))
truncates X
or pads X
with trailing zeros before taking the transform according to the elements of the vector sz
. Each element of sz
defines the length of the corresponding transform dimensions. For example, if X
is a 5-by-5-by-5 array, then Y = fftn(X,[8 8 8])
pads each dimension with zeros resulting in an 8-by-8-by-8 transform Y
.
Examples
You can use the fftn
function to compute a 1-D fast Fourier transform in each dimension of a multidimensional array.
Create a 3-D signal X
. The size of X
is 20-by-20-by-20.
x = (1:20)'; y = 1:20; z = reshape(1:20,[1 1 20]); X = cos(2pi0.01x) + sin(2pi0.02y) + cos(2pi0.03*z);
Compute the 3-D Fourier transform of the signal, which is also a 20-by-20-by-20 array.
Pad X
with zeros to compute a 32-by-32-by-32 transform.
m = nextpow2(20); Y = fftn(X,[2^m 2^m 2^m]); size(Y)
Input Arguments
Input array, specified as a matrix or a multidimensional array. If X
is of type single
, then fftn
natively computes in single precision, and Y
is also of type single
. Otherwise, Y
is returned as type double
.
Data Types: double
| single
| int8
| int16
| int32
| uint8
| uint16
| uint32
| logical
Complex Number Support: Yes
Length of the transform dimensions, specified as a vector of positive integers. The elements of sz
correspond to the transformation lengths of the corresponding dimensions of X
.length(sz)
must be at leastndims(X)
.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| logical
More About
The discrete Fourier transform Y of an _N_-D array X is defined as
Each dimension has length mk for k = 1,2,...,N, and ωmk=e−2πi/mk are complex roots of unity where i is the imaginary unit.
Extended Capabilities
Usage notes and limitations:
- The
sz
argument must have a fixed size. - For MEX output, MATLAB® Coder™ uses the library that MATLAB uses for FFT algorithms. For standalone C/C++ code, by default, the code generator produces code for FFT algorithms instead of producing FFT library calls. To generate calls to a specific installed FFTW library, provide an FFT library callback class. For more information about an FFT library callback class, see coder.fftw.StandaloneFFTW3Interface (MATLAB Coder).
- For simulation of a MATLAB Function block, the simulation software uses the library that MATLAB uses for FFT algorithms. For C/C++ code generation, by default, the code generator produces code for FFT algorithms instead of producing FFT library calls. To generate calls to a specific installed FFTW library, provide an FFT library callback class. For more information about an FFT library callback class, see coder.fftw.StandaloneFFTW3Interface (MATLAB Coder).
- Using the Code Replacement Library (CRL), you can generate optimized code that runs on ARM® Cortex®-A processors with Neon extension. To generate this optimized code, you must install theEmbedded Coder® Support Package for ARM Cortex-A Processors (Embedded Coder). The generated code for ARM Cortex-A uses the Ne10 library. For more information, see Ne10 Conditions for MATLAB Functions to Support ARM Cortex-A Processors (Embedded Coder).
- Using the Code Replacement Library (CRL), you can generate optimized code that runs on ARM Cortex-M processors. To generate this optimized code, you must install the Embedded Coder Support Package for ARM Cortex-M Processors (Embedded Coder). The generated code for ARM Cortex-M uses the CMSIS library. For more information, see CMSIS Conditions for MATLAB Functions to Support ARM Cortex-M Processors (Embedded Coder).
Usage notes and limitations:
- The
sz
argument must have a fixed size.
The fftn
function supports GPU array input with these usage notes and limitations:
- The output
Y
is always complex even if all the imaginary parts are zero.
For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced before R2006a