So I have this matrix M=(50,50,250) and I want to get the FFT2 of the slices S=(50,50) along the 3rd dimension = 250.
Let's say I do
FT = fftshift(fft2(M));
Is this calculating the FT as I want?
Because in the function description it says the function returns the 2-D DFT for each higher dimensional slice of X. For example, if size(X) = [100 100 3], then fft2 computes the DFT of X(:,:,1), X(:,:,2) and X(:,:,3).
So, I am assuming it is computing the FT of the slices S=(50x250) along the 1st dimension = 50.
Can someone clear this to me?
fftshift
! Prakhar’s answer tells you how to use its second argument to tell it what dimension to shift in, but I have run into so many bugs by forgetting that second argument tofftshift
that I made my owni/fftshift
function that errors if you don’t give it a second argument when the first argument is 2D/ND array! – Ahmed Fasih