Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Matlab: Your closest.m file will contain the definition of a function called closest which takes two vectors, a vector of r coordinates called xs

Using Matlab:

image text in transcribed

image text in transcribed

Your closest.m file will contain the definition of a function called closest which takes two vectors, a vector of r 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 r 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 r-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! (If you don't know what those terms mean, don't worry about it.) The first and last lines in your closest.m file are given below: function pt - closest(xs, ys) % Your code should go here. end Using the points above as an example, your code should do the following when given the xs and ys vectors above: >>closest ([2, 7, 5, -1, 0 ], [3, -1, 0, -1, 2]) ans- This indicates that of the points given, (-1, -1) was the point closest to the origin The

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions