Part a Write and save a userdefined function called Midpoint

Part a)  Write and save a user-defined function called MidpointDist(ax, ay, bx, by) that returns the distance to the middle of two points a andb in the plane. The formula for midpoint distance is:

For example, if a is the point (1, 0) and b is (3, 2), then the distance to the midpoint is:

Part b) In the command window, use the function you wrote to calculate the distance between the points:

(1, 2) and (–5, 5)

This needs to be done in matlab

Solution

follow this steps,

part A).

1.open matlab.

2.open new file.

3.copy the following code into new file.

function distance=MidpointDist(ax,ay,bx,by)
{
distance=sqrt(((ax+bx)/2)^2+((ay+by)/2)^2))
}

4.save the file as MidpointDist.m

part B).

goto command window

type MidpointDist(1,2,-5,5)

Part a) Write and save a user-defined function called MidpointDist(ax, ay, bx, by) that returns the distance to the middle of two points a andb in the plane. Th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site