14. Write a user-defined MATLAB function that determines the unit vector in the direction of the line

Question:

14. Write a user-defined MATLAB function that determines the unit vector in the direction of the line that connects two points (A and B) in space. For the function name and arguments, use n = unitvec(A,B). The input to the function are two vectors A and B, each with the Cartesian coordinates of the corresponding point. The output n is a vector with the components of the unit vector in the direction from A to B. If points A and B have two coordinates each (they are in the x y plane), then n is a two-element vector. If points A and B have three coordinate each (general points in space), then n is a three-element vector. Use the function to determine the following unit vectors:

(a) In the direction from point (–0.7, 2.1) to point (9, 18).

(b) In the direction from point (10, –3.5, –2.5) to point (–11, 6.5, 5.9).

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: