Question: a. Define a function named maxDistToCenter that takes 2 arguments as input: a single point, called the center, and a list of other points. The

a. Define a function named maxDistToCenter that takes 2 arguments as input: a single point, called the center, and a list of other points. The first line of the function should look like: function result = maxDistToCenter(center, other_pts) You may assume that center is a 1 x 2 vector containing the x-and y-coordinates of the center point and that other_pts is a Nx 2 matrix containing the X- and y-coordinates of N points, one point on each row. The function should return the maximum distance between the center and the other points. For example, o maxDistToCenter([1, 2], [1, 2]) should return 0 (the maximum distance between (1, 2) and (1, 2)) o maxDistToCenter([0, ], [3, 4]) should return 5 (the maximum distance between (0,0) and (3, 4)) maxDistToCenter([, 0], [1, 3; 2, 2; 3, 1]) should return the decimal approximation of the square root of 10, i.e., 3.162277660168380 (the maximum distance between (0,0) and (1,3), (2, 2), and (3, 1)) 0 Note: you will want to use MATLAB's max function; however, you will need to write the code that uses the distance formula to calculate the distance (MATLAB has a distance function, but it does not do what we want for this problem). b. Demonstrate that your function works by adding code to your main homework script to call your function with the given center and other points. Display the results in the following format: Maximum distance to (X,Y) is N where X, Y, and N are replaced with the appropriate values. In order to receive full credit for this problem, you must must make appropriate use of the disp and num2str commands. center other points 1. (1, 1) (8,3) 2. (3,3) (0, 1), (2, 3), (4,5),(6, 7), (8,9) 3. (7,5) (0, 1), (2,3), (4,5), (6, 7), (8,9)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
