Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

flipdim

Matrix Flipping (Matlab Style)


Description

Flip matrices up and down or left and right; or circulating indices per dimension.

Usage

flipdim(a, dim)
flipud(a)
fliplr(a)
circshift(a, sz)

Arguments

a

numeric or complex matrix

dim

flipping dimension; can only be 1 (default) or 2

sz

integer vector of length 1 or 2.

Details

flipdim will flip a matrix along the dim dimension, where dim=1 means flipping rows, and dim=2 flipping the columns.

flipud and fliplr are simply shortcuts for flipdim(a, 1) resp. flipdim(a, 2).

circshift(a, sz) circulates each dimension (should be applicable to arrays).

Value

the original matrix somehow flipped or circularly shifted.

Examples

a <- matrix(1:12, nrow=3, ncol=4, byrow=TRUE)
flipud(a)
fliplr(a)

circshift(a, c(1, -1))
v <- 1:10
circshift(v, 5)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.