ifftshift

Undoes fftshift, moving the centered zero frequency back to the start.

Category: Mathematics > Fourier Analysis and Filtering

Syntax

Y = ifftshift(X)

Reverses fftshift along every dimension.

Y = ifftshift(X, dim)

Reverses it along dimension dim only.

Description

It circularly shifts each dimension by ceil(n/2), the inverse of the floor(n/2) shift done by fftshift. The two agree for even lengths and differ by one position for odd lengths, so use ifftshift rather than fftshift before an inverse transform to be safe in both cases.

Input arguments

X
Array in centered-spectrum order.
dim
Dimension to shift along.

Output arguments

Y
Array in the order that ifft expects.

Example

Odd length round trip

x = 1:5;
ifftshift(x)
ifftshift(fftshift(x))
Output
ans = 1×5

     3     4     5     1     2
ans = 1×5

     1     2     3     4     5

See also

fftshift ifft ifft2 circshift