Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.2 - Português

Change language to:
English - Français - 日本語 - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Ajuda do Scilab >> Processamento de Sinais > Transforms > ifftshift

ifftshift

inverse of fftshift

Syntax

y = ifftshift(x)
y = ifftshift(x, along)

Arguments

x, y

vectors, matrices or hypermatrices of same sizes and types.

along

1 | "r" | 2 | "c" | 0<along<=ndims(x): dimension along which halves are switched.

Description

ifftshift(x) swaps the left and right halves of the vector x.

For matrices, ifftshift(x) swaps the first quadrant with the third, and the second quadrant with the fourth.

If x is a multidimensional array, ifftshift(x) swaps "half-spaces" of x along each dimension, for all of them.

y = ifftshift(x,n) makes the swap only along the nth dimension.

ifftshift() is designed in such a way that whatever is x with even or/and odd sizes, ifftshift(fftshift(x)) and fftshift(ifftshift(x)) are always equal to x.

Examples

Example #1:

When the size of a vector (or of a dimension>1) is even, fftshift() and ifftshift() are equivalent. It is no longer the case when a size is odd:

even = [1 2 3 4 5 6];
odd  = [1 2 3 4 5 6 7];
[fftshift(even) ; ifftshift(even)]
[fftshift(odd)  ; ifftshift(odd)]

// Both are always reciprocal:
ifftshift(fftshift(odd))
fftshift(ifftshift(odd))
--> even = [1 2 3 4 5 6];
--> odd  = [1 2 3 4 5 6 7];
--> [fftshift(even) ; ifftshift(even)]
 ans  =
   4.   5.   6.   1.   2.   3.
   4.   5.   6.   1.   2.   3.

--> [fftshift(odd)  ; ifftshift(odd)]
 ans  =
   5.   6.   7.   1.   2.   3.   4.
   4.   5.   6.   7.   1.   2.   3.

--> // Both are always reciprocal:
--> ifftshift(fftshift(odd))
 ans  =
   1.   2.   3.   4.   5.   6.   7.

--> fftshift(ifftshift(odd))
 ans  =
   1.   2.   3.   4.   5.   6.   7.

Example #2:

// Make a signal
t = 0:0.1:1000;
x = 3*sin(t) + 8*sin(3*t) + 0.5*sin(5*t) + 3*rand(t);
// Compute the fft
y = fft(x, -1);
// Invert the result
shift = fftshift(y);
// Invert the inverted result
invShift = ifftshift(shift);
// Check that we recreated the original result
and(y == invShift)

Example #3:

// Make a 2D image
t = 0:0.1:30;
x = 3*sin(t')*cos(2*t) + 8*sin(3*t')*sin(5*t) + ..
  0.5*sin(5*t')*sin(5*t) + 3*rand(t')*rand(t);
// Compute the fft
y = fft(x,-1);

// Invert the result
shift = fftshift(y);
// Invert the inverted result
invShift = ifftshift(shift);
// Check that we recreated the original result
and(y == invShift)

See also

  • fftshift — rearranges the fft output, moving the zero frequency to the center of the spectrum
  • fft — fast Fourier transform.
  • flipdim — reverses the order of (blocks of) rows, columns, pages.. of an array

History

VersãoDescrição
6.0.2 Option along added.
Report an issue
<< hilb Transforms bilt >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:00:44 CET 2019