How to calculate the coefficients of a line in the standard form

9 views (last 30 days)
I need a MATLAB code to calculate A, B, and C in Ax+By+C=0 considering two points
x1=-2; x2=3; y1=4; y2=-5
Thanks

Answers (1)

Image Analyst
Image Analyst on 17 Jun 2021
x1=-2; x2=3; y1=4; y2=-5
coefficients = polyfit([x1,x2], [y1, y2], 1)
% I need a MATLAB code to calculate A, B, and C in Ax+By+C=0
% Equation is y = coefficients(1) * x + coefficients(2), or
% coefficients(1) * x + coefficients(2) - y = 0
% so
A = coefficients(1)
B = 1
C = coefficients(2)
coefficients =
-1.8 0.399999999999999
A =
-1.8
B =
1
C =
0.399999999999999

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!