[v, mask] = flag_bad(v, sig_max )
Calculate the mean value of the non-NaN in a vector, standard deviation and residuals for each element. An element is considered as bad if the absolute value of its residual is larger than a certain threshold value. The latter is determined as a factor times the standard deviation.
This function can be used to detect vector elements that are much more different than the other ones.
Data vector.
Factor used to calculate the threshold value. A typical value is 2.5.
Vector with bad elements replaced by NaN.
Vector of ones or zeros,zeros specifying elements in v that have been flagged as bad,or that were already set to NaN on input.
Pierre Jaccard, Geophysical Institute, University of Bergen, 1999