Hi I need help to do this program in MATLAB CODE Write a pro

Hi! I need help to do this program in MATLAB CODE:

Write a program that asks the user the x & y coordinates of two points (4 total inputs: x1, y1, x2, y2). The program should show the user the distance between the points and the slope of the line connecting point 1 to point 2.

Thanks a lot!

Solution

Code:

x1 = input(\'Enter x1:\');
y1 = input(\'Enter y1:\');
x2 = input(\'Enter x2:\');
y2 = input(\'Enter y2:\');
distance = sqrt((x2-x1).^2+(y2-y1).^2);
angle = atan2((x2 - x1), (y2 - y1)) * 180 / pi;
fprintf(\'Distance is:%.2f\ \',distance);
fprintf(\'Angle is:%.2f\ \',angle);

Output:

Enter x1:2
Enter y1:3
Enter x2:5
Enter y2:6
Distance is:4.24
Angle is:45.00

Hi! I need help to do this program in MATLAB CODE: Write a program that asks the user the x & y coordinates of two points (4 total inputs: x1, y1, x2, y2).

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site