I am trying to re-implement one of the matlab toolboxes.
they use fft over there.
when i perform same operation on the same data i get different results to those from matlab.
Just take a look:
MATLAB:
Msig =
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 1 0 0
0 0 0 0
fft(Msig.')
Columns 1 through 4
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
Columns 5 through 6
1.0000 0
0 - 1.0000i 0
-1.0000 0
0 + 1.0000i 0
PYTHON:
Msig=
array([[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 0., 0., 0.],
[ 0., 1., 0., 0.],
[ 0., 0., 0., 0.]])
np.fft.fft(Msig.transpose())
array([[ 0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j,
0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j,
0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j],
[ 1.0 +0.00000000e+00j, -0.5 +8.66025404e-01j,
-0.5 -8.66025404e-01j, 1.0 -3.88578059e-16j,
-0.5 +8.66025404e-01j, -0.5 -8.66025404e-01j],
[ 0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j,
0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j,
0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j],
[ 0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j,
0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j,
0.0 +0.00000000e+00j, 0.0 +0.00000000e+00j]])
The best i can get if i mess with parameters(axis etc.) of np.fft.fft()/np.fft.fft2()/np.fft.fftn() is same values but shifted. unfortunately manual shifting is not an option cause the size and shape of the Msig matrix varies depending on input parameters.
you have any clue how to solve this problem, what can be the cause?
See Question&Answers more detail:
os