| Mapping Toolbox | ![]() |
Replace entries of a matrix map specified by a mask matrix
Syntax
mapout = maskm(map,mask) mapout = maskm(map,mask,newcode)
Description
mapout = maskm(map,mask,newcode) returns a matrix map mapout identical to the matrix map, map, except that every element corresponding to a 1 in mask is replaced with the scalar value newcode. mask is a matrix of 1s and 0s, the same size as map. The mask can be the result of a logical operation on the variable map (e.g., mask = (map>100)). When no newcode is supplied, NaNs are inserted.
Examples
map = magic(3)
map =
8 1 6
3 5 7
4 9 2
Use a logical test on the map as a mask. Replace with the default value (NaN):
mapout = maskm(map,(map>5))
mapout =
NaN 1 NaN
3 5 NaN
4 NaN 2
See Also
changem |
Replace certain values in a matrix map |
| maptrims | mat2dms | ![]() |