Fft In Matlab And Numpy / Scipy Give Different Results
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. Ju
Solution 1:
Matlab applies the fft over the columns of the matrix, numpy applies the fft over the last axis (the rows) by default. You want:
>>> np.fft.fft(Msig.T, axis=0)
array([[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.-1.j, 0.+0.j],
[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, -1.+0.j, 0.+0.j],
[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+1.j, 0.+0.j]])
or
>>> np.fft.fft(Msig).T
array([[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j],
[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.-1.j, 0.+0.j],
[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, -1.+0.j, 0.+0.j],
[ 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+1.j, 0.+0.j]])
Post a Comment for "Fft In Matlab And Numpy / Scipy Give Different Results"