MATLAB Puzzler: Finding the two closest points
Here is a new MATLAB Puzzler.
Given two vectors representing the X and Y coordinates of some points, find the two closest points in Cartesian space.
Brett and I took very different paths to solving this problem, he knows more about the statistics toolbox than I do and found a much shorter solution because there is a function that basically does this. As a benchmark. sticking with base MATLAB, I solved this in seven lines of code.
Post your solutions in the comments area along with how long it took you to solve.
n = 10;
x = rand(1,n);
y = rand(1,n);
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.