In Line 253, when calculating the distances for more than two dimensions, the code was
d = sqrt(sum((X(i,:)-X(j,:)).^2));
I think it should be
d = sqrt(sum((X(i,:)-X(j,:)).^2,2));
as we need the sums of the rows but not the columns. After this correction, everything works perfectly in calculating 3-dimensional variograms.
Many thanks for your function. It is absolutely fabulous!
@Mani Ahmadian: Hi Mani, thanks for your comment. I don't have a good method for dealing with outliers using variogramfit except using an optimization scheme other than "least squares". E.g., least absolute deviations may be less sensitive to outliers. In case you are supplying variogramfit with the binned, experimental variogram, I'd better care for outliers during binning. For example, you might want to adapt the function variogram ( http://www.mathworks.com/matlabcentral/fileexchange/20355-experimental--semi---variogram ) to compute the trimmed mean or median when aggregating binned variogram values.
22 Dec 2014
fits different theoretical variograms to an experimental variogram