%% 3-D Transform
% 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(2*pi*0.01*x) + sin(2*pi*0.02*y) + cos(2*pi*0.03*z);

%
% Compute the 3-D Fourier transform of the signal, which is also a 20-by-20-by-20 array.

Y = fftn(X);

%
% 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)

% Copyright 2012 The MathWorks, Inc.