fft2

Two Dimensional Fast Fourier Transform.

Syntax

f = fft2(x)

f = fft2(x,m,n)

Inputs

x
The signal to be transformed into the frequency domain.
Type: double
Dimension: vector | matrix
m
The number of columns in the fft.
Type: integer
Dimension: scalar
n
The number of rows in the fft.
Type: integer
Dimension: scalar

Outputs

f
The frequency domain representation of x.

Example

Magnitude plot of fft2 for a signal with two frequency components in each direction.

f1x = 25;              % first x frequency component
f2x = 40;              % second x frequency component
fsx = 100;             % sampling frequency in x
tsx = 1/fsx;           % sampling time interval in x
n = 20;	         % number of x samples
tx = [0:1:(n-1)]*tsx;  % x time vector
signalx = 20*sin(2*pi*f1x*tx) + 8*sin(2*pi*f2x*tx);
fqx = freq(n,fsx);     % x frequency vector
f1y = 60;              % first y frequency component
f2y = 80;              % second y frequency component
fsy = 200;             % sampling frequency in y
tsy = 1/fsx;           % sampling time interval in y
m = 10;	         % number of y samples
ty = [0:1:(m-1)]*tsy;  % y time vector
signaly = 12*sin(2*pi*f1y*ty) + 16*sin(2*pi*f2y*ty);
%pad = 4;
%m = pad * m;
fqy = freq(m,fsy); % y frequency vector
signal = signaly' * signalx;
ft = fft2(signal,m,n) / (m*n); % normalized fft2
contour3(fqx, fqy, abs(ft));
Figure 1. fft2

Comments

The dimensions of the fft2(m, n), default to the dimensions of the matrix being transformed. If m, n are not the defaults, the signal matrix is either truncated or extended with zeros to the specified length. fft2 uses the fftW library.