Tuesday, August 4, 2009

fftn

Multidimensional discrete Fourier transform

Syntax

  • Y = fftn(X)
    Y = fftn(X,siz)

Description

Y = fftn(X) returns the discrete Fourier transform (DFT) of X, computed with a multidimensional fast Fourier transform (FFT) algorithm. The result Y is the same size as X.

Y = fftn(X,siz) pads X with zeros, or truncates X, to create a multidimensional array of size siz before performing the transform. The size of the result Y is siz.

Algorithm

fftn(X) is equivalent to

  • Y = X;
    for p = 1:length(size(X))
    Y = fft(Y,[],p);
    end

This computes in-place the one-dimensional fast Fourier transform along each dimension of X. The execution time for fft depends on the length of the transform. It is fastest for powers of two. It is almost as fast for lengths that have only small prime factors. It is typically several times slower for lengths that are prime or which have large prime factors.



fftshift

Shift zero-frequency component of discrete Fourier transform to center of spectrum

Syntax

  • Y = fftshift(X)
    Y = fftshift(X,dim)

Description

Y = fftshift(X) rearranges the outputs of fft, fft2, and fftn by moving the zero-frequency component to the center of the array. It is useful for visualizing a Fourier transform with the zero-frequency component in the middle of the spectrum.

For vectors, fftshift(X) swaps the left and right halves of X. For matrices, fftshift(X) swaps quadrants one and three of X with quadrants two and four. For higher-dimensional arrays, fftshift(X) swaps "half-spaces" of X along each dimension.

Y = fftshift(X,dim) applies the fftshift operation along the dimension dim.

Examples

For any matrix X

  • Y = fft2(X)

has Y(1,1) = sum(sum(X)); the zero-frequency component of the signal is in the upper-left corner of the two-dimensional FFT. For

  • Z = fftshift(Y)

this zero-frequency component is near the center of the matrix.

No comments:

Post a Comment