% % % C = rand(40000,4); Q = rand(4000,4); disp ('C-Q'); disp ('build-in') tic; [i1, d1] = knnsearch(C, Q, 'k', 4); toc disp ('mine') tic; [i2, d2] = knnsearch2(C, Q, 4); toc sum(i1-i2) sum(d1-d2) disp (' '); disp (' '); disp ('C-C'); disp ('build-in') tic; [i1, d1] = knnsearch(C, C, 'k', 4); toc disp ('mine') tic; [i2, d2] = knnsearch2(C, C, 4); toc sum(i1-i2) sum(d1-d2)