Very nice function and quite useful with the little extras.
Please note the strmatch function being used will be replaced in a future version of MATLAB. Replacing it with strncmp fixes the warning. Please update the file some time in the future.
Keith - I just submitted a fix for that case. The new version should appear online in the morning. It happens because the result was essentially zero for some elements, but floating point arithmetic errors can drive a value less than zero, then a sqrt is taken.