Problem 450. What is the distance from point P(x,y) to the line Ax + By + C = 0?
Given a point, P(x,y), find the distance from this point to a linear line.
INPUTS: x, y, A, B, C
OUTPUTS: d, the distance which of course should always be positive.
EX: >>x=2; y=2; A=2; B=2; C=-4; >>d = normalLen(x,y,A,B,C) d = 1.4142
Solution Stats
Problem Comments
-
2 Comments
Claudio Gelmi
on 23 Jan 2013
There is a mistake with the solution of Test #3. Ans should be 7.40. Please check.
Nicolas Douillet
on 29 Nov 2022
I confirm this error.
Solution Comments
Show commentsProblem Recent Solvers362
Suggested Problems
-
Back to basics 22 - Rotate a matrix
887 Solvers
-
439 Solvers
-
Getting the row and column location from a matrix
282 Solvers
-
Return the first and last characters of a character array
9016 Solvers
-
Matrix multiplication across rows
304 Solvers
More from this Author16
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!