function [output1, output2] = fft2D(input)
output1 = input';
output1 = fft(output1);
output1 = output1';
output1 = fft(output1);
output2 = fft2(input);
end
So I calculate in output2 the 2D FFT of input
and in output1 the same 2D FFT of input
. fft()
applies, for a 2D matrix, FFT across the column vectors. So above I apply it over the rows and then over the columns.
However for a random matrix
[1 1 4 1;
12 13 124 1;
12 2 2 1;
1 1 1 0]
my output1
is:
1.0e+02 *
1.7700 + 0.0000i -1.0500 + 0.1400i 1.3700 + 0.0000i -1.0500 - 0.1400i
-0.1000 - 1.4700i -0.0200 + 1.1100i -0.0800 - 1.2100i -0.2400 + 1.1300i
-1.2900 + 0.0000i 1.1900 - 0.1200i -1.0900 + 0.0000i 1.1900 + 0.1200i
-0.1000 + 1.4700i -0.2400 - 1.1300i -0.0800 + 1.2100i -0.0200 - 1.1100i
and my output2
is
1.0e+02 *
1.7700 + 0.0000i -1.0500 - 0.1400i 1.3700 + 0.0000i -1.0500 + 0.1400i
-0.1000 - 1.4700i -0.2400 + 1.1300i -0.0800 - 1.2100i -0.0200 + 1.1100i
-1.2900 + 0.0000i 1.1900 + 0.1200i -1.0900 + 0.0000i 1.1900 - 0.1200i
-0.1000 + 1.4700i -0.0200 - 1.1100i -0.0800 + 1.2100i -0.2400 - 1.1300i
They are the same values but interchanged in various positions! This has been driving me crazy for a long time, because from what I've (re)read online 2D FFT can be performed by applying 1D FFT across rows and then columns. Any help or suggestion would be great!