ifftshift is an R equivalent to the Matlab function ifftshift
applied on matrices. For more information about ifftshift see
the Matlab documentation.
Details
ifftshift is the inverse function to fftshift. For more
information see the details of fftshift
Examples
set.seed(987)
sampleMat <- matrix(sample(1:10, size = 25, replace = TRUE), nrow = 5)
# Swap halves along the rows:
ifftshift(sampleMat, dimension = 1)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 7 3 2 3 3
#> [2,] 2 2 5 10 10
#> [3,] 8 8 10 8 8
#> [4,] 9 1 4 3 9
#> [5,] 9 1 2 9 9
# Swap halves along the columns:
ifftshift(sampleMat, dimension = 2)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 4 3 9 9 1
#> [2,] 2 9 9 9 1
#> [3,] 2 3 3 7 3
#> [4,] 5 10 10 2 2
#> [5,] 10 8 8 8 8
# Swap first quadrant with third and second quadrant with fourth:
ifftshift(sampleMat, dimension = -1)
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 2 3 3 7 3
#> [2,] 5 10 10 2 2
#> [3,] 10 8 8 8 8
#> [4,] 4 3 9 9 1
#> [5,] 2 9 9 9 1