# padarray: MATLAB padarray function In matlab: MATLAB emulation package

## Usage

 `1` ```padarray(A, padsize, padval=0, direction=c("both", "pre", "post")) ```

## Arguments

`A`

vector, matrix, or array to be padded

`padsize`

integer vector specifying both amount of padding and the dimension along which to add it

`padval`

scalar value specifying pad value, which defaults to 0.
Instead, it may specify the method used to determine pad values.
Valid values for the method are:

 `"circular"` pad with circular repetition of elements within the dimension `"replicate"` pad by repeating border elements of array `"symmetric"` pad array with mirror reflections of itself
`direction`

character string specifying direction to apply padding.
Valid values are:

 `"both"` pad before first element and after last array element along each dimension `"pre"` pad after last array element along each dimension `"post"` pad before first array element along each dimension

## Details

This is an S4 generic function.

## Value

Return value is the same type as argument `A` with requested padding.

## Author(s)

P. Roebuck [email protected]

## Examples

 ```1 2 3 4 5 6``` ```padarray(1:4, c(0, 2)) # 0 0 [1 2 3 4] 0 0 padarray(1:4, c(0, 2), -1) # -1 -1 [1 2 3 4] -1 -1 padarray(1:4, c(0, 2), -1, "post") # [1 2 3 4] -1 -1 padarray(1:4, c(0, 3), "symmetric", "pre") # 3 2 1 [1 2 3 4] padarray(letters[1:5], c(0, 3), "replicate") # a a a [a b c d e] e e e padarray(letters[1:5], c(0, 3), "circular", "post") # [a b c d e] a b c ```

### Example output

```Attaching package: 'matlab'

The following object is masked from 'package:stats':

reshape

The following objects are masked from 'package:utils':

find, fix

The following object is masked from 'package:base':

sum

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]    0    0    1    2    3    4    0    0
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]   -1   -1    1    2    3    4   -1   -1
[,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    2    3    4   -1   -1
[1] 3 2 1 1 2 3 4
[1] "a" "a" "a" "a" "b" "c" "d" "e" "e" "e" "e"
[1] "a" "b" "c" "d" "e" "a" "b" "c"
```

matlab documentation built on May 30, 2017, 6:57 a.m.