Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Matlab please.... The standard form of the equation of a straight Line in

ID: 3573046 • Letter: U

Question

Using Matlab please....

The standard form of the equation of a straight Line in the x-y plane is: A x + B y + C = 0, and a point in the plane is defined by its coordinates (x_0, y_0). Write a user-defined MATLAB function that determines the distance between a point and a straight line in the x-y plane. For the function name and arguments use: d = PtoLdist(x_0, y_0, A, B, C) where the input arguments are the coordinates of the point and the three constants of the equation of the line. The output argument is the distance. Use the function to determine the distance for the following cases: Point: (2, - 4), line: - 2x + 3.5y - 6 = 0. Point: (11, 2), line: y = - 2x + 6,

Explanation / Answer

PtoLdist.m

function d = PtoLdist(xo, yo, A, B, C)
d = abs(A*xo + B*yo + C)/sqrt(A^2 + B^2);

script.m (driver file)

dist1 = PtoLdist(2, -4, -2, 3.5, -6);
dist2 = PtoLdist(11, 2, -2, -1, 6);
disp(['Distance 1 = ', num2str(dist1)]);
disp(['Distance 2 = ', num2str(dist2)]);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote