# I am getting different values of fft for the same variable as demonstrated by a simple example below...

4 views (last 30 days)
Yogesh on 9 May 2024
Answered: Paul on 11 May 2024
E=[1 2 4 6;3 6 3 9;7 5 8 9]
E = 3x4
1 2 4 6 3 6 3 9 7 5 8 9
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
EF=fftshift(abs(fft(E)))
EF = 3x4
4.5826 3.0000 5.2915 3.6056 15.0000 24.0000 11.0000 13.0000 4.5826 3.0000 5.2915 3.6056
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
ES=fftshift(abs(fft(E(:,1))))
ES = 3x1
5.2915 11.0000 5.2915
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
shouldn't ES be equal to the first row of EF...

Paul on 11 May 2024
I think you were expecting ES be equal to the first column of EF.
If desired for fftshift to work along a specific dimension of the input, then that dimension needs to be specified
E=[1 2 4 6;3 6 3 9;7 5 8 9];
EF=fftshift(abs(fft(E)),1) % specify the dimension
EF = 3x4
5.2915 3.6056 4.5826 3.0000 11.0000 13.0000 15.0000 24.0000 5.2915 3.6056 4.5826 3.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
ES=fftshift(abs(fft(E(:,1))))
ES = 3x1
5.2915 11.0000 5.2915
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
If that second argument to fftshift is not specified, then the the 2D input is assumed to be a 2D fft, as might be produced from fft2, and the shifting is done in both dimensions.