Added code for kNN with older versions of Matlab