Perform a shift of the vector v, for use with the
fft
andifft
functions, in order the move the frequency 0 to the center of the vector or matrix.If v is a vector of N elements corresponding to N time samples spaced of Dt each, then
fftshift (fft (
v))
corresponds to frequenciesf = ((1:N) - ceil(N/2)) / N / DtIf v is a matrix, the same holds for rows and columns. If v is an array, then the same holds along each dimension.
The optional dim argument can be used to limit the dimension along which the permutation occurs.