Question: Need Problem 2 answer please in MathLab my code for #1 x1=input('Input the coordinate x for the first point: '); y1=input('Input the coordinate y for

Need Problem 2 answer please in MathLabNeed Problem 2 answer please in MathLab my code for #1 x1=input('Input

my code for #1

x1=input('Input the coordinate x for the first point: '); y1=input('Input the coordinate y for the first point: '); x2=input('Input the coordinate x for the second point: '); y2=input('Input the coordinate y for the second point: '); distance= sqrt(((x2-x1)^2) + ((y2-y1)^2)); slope=(y2-y1)/(x2-x1); intercept= y1-(slope*x1); fprintf('The distance between the 2 points is: %.2f ',distance); fprintf('The slope is: %.2f ',slope); fprintf('The intercept is: %.2f ',intercept); if intercept >= 0 fprintf('The ecuation of the line is: Y = %.2f X + %.2f ',slope,intercept); else printf('The ecuation of the line is: Y = %.2f X - %.2f ',slope,abs(intercept)); end

Given the x,y coordinates of two points in rectangular space (x1,yl) and (x2,y2), write a script program to calculate a) The distance between the two points b) The slope of the line c) The intercept of the line with the y axis d) The equation of the line The program should prompt (ask) the user for x1y1.x2,y2 and print similar output below (your output should be similar in format to the example output below but of course with your calculated numbers) The distance between the two point is: 4 The slope is: -1.5 The intercept is: 3.6 The equation of the line is: Y= -1.5 X+3.6 Math notes: The distance between two points is square root of sum of squares of y2 yl and x2-x1 The slope is (y2-yl)/(x2-x1)|| The intercept for straight line equation of the form y=ax + b where a is the slope and bis intercept is b=y/ax Problem 2: Write the above program as a function to return distance, slope and intercept No word output necessary. The function would take the four input arguments xl,y1,x2,y2 and return three output arguments [ distance, slope, intercept]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!