ifftshift is an R equivalent to the Matlab function ifftshift applied on matrices. For more information about ifftshift see the Matlab documentation.

ifftshift(inputMatrix, dimension = -1)

Arguments

inputMatrix

Matrix to be swapped.

dimension

Which swap should be performed?

  • 1: swap halves along the rows.

  • 2: swap halves along the columns.

  • -1: swap first quadrant with third and second quadrant with fourth.

Value

Swapped matrix.

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 4 2 10 2 #> [2,] 6 9 4 1 8 #> [3,] 9 8 2 8 10 #> [4,] 5 3 2 7 8 #> [5,] 10 5 4 2 6
# Swap halves along the columns: ifftshift(sampleMat, dimension = 2)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 2 7 8 5 3 #> [2,] 4 2 6 10 5 #> [3,] 2 10 2 7 4 #> [4,] 4 1 8 6 9 #> [5,] 2 8 10 9 8
# Swap first quadrant with third and second quadrant with fourth: ifftshift(sampleMat, dimension = -1)
#> [,1] [,2] [,3] [,4] [,5] #> [1,] 2 10 2 7 4 #> [2,] 4 1 8 6 9 #> [3,] 2 8 10 9 8 #> [4,] 2 7 8 5 3 #> [5,] 4 2 6 10 5