fftn

N-dimensional discrete Fourier transform.

Category: Mathematics > Fourier Analysis and Filtering

Syntax

Y = fftn(X)

Transforms along every dimension of X.

Y = fftn(X, sz)

Zero-pads or truncates X to the size vector sz first.

Description

fftn applies fft in turn along each dimension, which for a matrix gives the same result as fft2. For a volume it transforms along all three axes. Y(1,1,...,1) is always the sum of every element.

Undo it with ifftn.

Input arguments

X
Numeric array of any number of dimensions.
sz
Vector with the transform length in each dimension.

Output arguments

Y
N-D spectrum of the same size as sz (or X).

Example

Matches fft2 on a matrix

X = [1 2; 3 4];
fftn(X)
isequal(fftn(X), fft2(X))
V = ones(2,2,2);
Y = fftn(V);
Y(1)
Output
ans = 2×2

    10    -2
    -4     0
ans = logical
   1
ans = 8

See also

ifftn fft fft2 fftshift convn