expandMatrix
Enlarge a matrix by extending the edge values.
Syntax
mat_new = expandMatrix(mat, exp_coeff) mat_new = expandMatrix(mat, exp_coeff, edge_val)
Description
expandMatrix
enlarges an input matrix by extension of the values at the outer faces of the matrix (endpoints in 1D, outer edges in 2D, outer surfaces in 3D). Alternatively, if an input for edge_val
is given, all expanded matrix elements will have this value. The values for exp_coeff
are forced to be real positive integers (or zero). Note, indexing is done inline with other k-Wave functions using mat(x)
in 1D, mat(x, y)
in 2D, and mat(x, y, z)
in 3D.
For example, running
mat = magic(3) expandMatrix(mat, 1) expandMatrix(mat, [2 0 1 0], 0)
will give the outputs
ans = 8 8 1 6 6 8 8 1 6 6 3 3 5 7 7 4 4 9 2 2 4 4 9 2 2 ans = 0 0 0 0 0 0 0 8 1 6 0 0 3 5 7 0 0 4 9 2
Inputs
mat |
the matrix to enlarge |
exp_coeff |
the number of elements to add in each dimension, where
(here |
Optional Inputs
edge_val |
value to use in the matrix expansion |
Outputs
mat_new |
expanded matrix |
See Also
trimZeros
, resize