Descriptive statistic to characterize & compare data sets.
Ronald Van Steenweghen
As used with time series, not surprisingly a NaN enters the dataset. Therefore I suggest to use the replace this line of code by:
cv = nanstd(x(:))/nanmean(x(:))*100;
This will return a result even if NaN's are included into the dataset.