Question: 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.

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 inputs to the function are two vectors A and B, each with the Cartesian coordinates of the corresponding point. The output 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 (1.2, 3.5) to point (12, 15)
(b) In the direction from point (-10, -4, 2.5) to point (-13, 6, -5)

Step by Step Solution

3.47 Rating (173 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Script file clear clc disp Part a A12 35 B12 15 n unitvec AB di... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

652-B-F-F-M (732).docx

120 KBs Word File

Students Have Also Explored These Related Finance Questions!