Question: By using Matlab: Your closest.m file will contain the definition of a function called closest which takes two vectors, a vector of x coordinates called
By using Matlab:
Your closest.m file will contain the definition of a function called closest which takes two vectors, a vector of x coordinates called xs and a vector of y coordinates called ys . We will assume both vectors have the same length, and the two vectors together give the x and y coordinates of a collection of points in the plane. For example, if the points in the plane are (2,3), (7,-1), (5,0), (-1,1), and (0,2) then xs would be the vector [2, 7, 5, -1, 0] and ys would be the vector [3, -1, 0, -1, 2] . Your function should then determine which of the points represented is closets to the origin and should return a vector whose first entry is the x -coordinate of that point and whose second entry is the y -coordinate. Furthermore, your code should work without you having to write any loops or use recursion!

This is what I've done, but something is wrong, the result can't find the closest point. Could u plz help me out? We can't use loops and recursion btw:)
closest.mlx 1+ 1 2 3 4 5 function pt -closest(xs, ys) dist = sqrt(xs.^2-ys.^2); [minxs, minys] min(dist); end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
