# tests/padarray.R In matlab: MATLAB emulation package

```###
### \$Id: padarray.R 51 2014-02-05 21:22:28Z plroebuck \$
###

##-----------------------------------------------------------------------------
identical(output, expected)
}

## The padding elements contain mirror copies of the array
padarray.expected.mat4x4 <- matrix(1:4, 4, 4, byrow = TRUE)
direction = "pre"),

## Add three elements of padding to the end of the first dimension of array
## and two elements of padding to the end of the second dimension.
## Use value of the last array element as the padding value.
Amat.2x2 <- matrix(as.numeric(1:4), nrow = 2, ncol = 2, byrow = TRUE)
padarray.expected.mat5x4 <- matrix(c(1, 2, 2, 2,
3, 4, 4, 4,
3, 4, 4, 4,
3, 4, 4, 4,
3, 4, 4, 4),
nrow = 5, ncol = 4, byrow = TRUE)
direction = "post"),

## Add three elements of padding to each dimension of a three-dimensional array.
## Each pad element contains the value zero.
Bmat.2x2 <- matrix(5:8, nrow = 2, ncol = 2, byrow = TRUE)
Carr.2x2x2 <- array(c(Amat.2x2, Bmat.2x2), c(2, 2, 2))
A <- array(0, c(8, 8, 2))
A[4:5, 4:5, 1] <- Amat.2x2
A[4:5, 4:5, 2] <- Bmat.2x2
A
}
direction = "both"),

## The padding elements contain a mirror copy of the vector