# numReplace

Below is a demonstration of the features of the `numReplace` function

## Contents

```
clear; close all; clc;
```

## REPLACING NUMBERS IN ARRAYS

An example array

A=[0,-6,3,0,0;-1,-4,-7,-9,-9;-4,-7,11,-5,12;10,-7,5,-7,13;0,11,-2,-6,2;12,4,2,-5,NaN]

A = 0 -6 3 0 0 -1 -4 -7 -9 -9 -4 -7 11 -5 12 10 -7 5 -7 13 0 11 -2 -6 2 12 4 2 -5 NaN

Defining the input array for entries (NaN's allows) that need to be replaced

a=[2 -5 nan 0]

a = 2 -5 NaN 0

Defining the numbers (NaN's allows) to take their place

```
b=[991 992 993 994]; %Numbers to take their place
```

Replacing the numbers using `numReplace`

B=numReplace(A,a,b)

B = 994 -6 3 994 994 -1 -4 -7 -9 -9 -4 -7 11 992 12 10 -7 5 -7 13 994 11 -2 -6 991 12 4 991 992 993

## NOTES ON PERFORMANCE FOR NON-INTEGERS

The `numReplace` function employs the `ismember` function. Hence it is suitable for all number cases where ismember is able to detect membership. Numerical precission difficulties may arise for non-integer entires. Consider the below:

logicMember=ismember(pi,pi+eps(pi)) logicMember=ismember(pi,pi+eps(pi)/10)

logicMember = logical 0 logicMember = logical 1

* GIBBON* www.gibboncode.org

*Kevin Mattheus Moerman*, [email protected]

**GIBBON footer text**

License: https://github.com/gibbonCode/GIBBON/blob/master/LICENSE

GIBBON: The Geometry and Image-based Bioengineering add-On. A toolbox for image segmentation, image-based modeling, meshing, and finite element analysis.

Copyright (C) 2017 Kevin Mattheus Moerman

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.