fftshift: Swap the quadrants or halves of a 2d matrix.

Description Usage Arguments Details Value Examples

View source: R/HelpFunctions.R

Description

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

Usage

1
fftshift(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.

Details

It is possible to swap the halves or the quadrants of the input matrix. Halves can be swapped along the rows (dimension = 1) or along the columns (dimension = 2). When swapping the quadrants, fftshift swaps the first quadrant with the third and the second quadrant with the fourth (dimension = -1).

Value

Swapped matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(987) 
sampleMat <- matrix(sample(1:10, size = 25, replace = TRUE), nrow = 5)

# Swap halves along the rows:
fftshift(sampleMat, dimension = 1)

# Swap halves along the columns:
fftshift(sampleMat, dimension = 2)

# Swap first quadrant with third and second quadrant with fourth:
fftshift(sampleMat, dimension = -1)

romanflury/mrbsizeR documentation built on Dec. 15, 2019, 9:30 p.m.