Hi I think there is a bug in nanmedian - i have a dataset (single row), DS, which contains no NaN values, but nanmedian(DS) = NaN. Matlab's normal median(DS)=0.
I think this is the problem - when the median actually equals zero, nanmedian thinks it =nan.
Thanks for the examples. I have a suggestion on orthogonal polynomial fitting. Forsythe suggests a way to solve for both the correct orthogonal polynomials to use and the coefficients. The advantage is the full normal equation never has to be solved. Both the orthogonal polynomials and there coefficients are solved. It seems like an excellent method of data fitting.
Forsythe, George E. "Generation and use of orthogonal polynomials for data-fitting with a digital computer." Journal of the Society for Industrial & Applied Mathematics 5.2 (1957): 74-88.