If x is your matrix, use the isnan function to index the array:
x( isnan(x) ) = 0
If you do this in two steps, then it is probably better to understand what is happening. First create an array of true / false values, then use this to set the selected items to zero.
bad = isnan(x); x(bad) = 0;
This is pretty simple stuff. It would be nice to read some of the MATLAB online tutorials to speed things up.
Justin
source share