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

9 次查看(过去 30 天)
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

回答(1 个)

Image Analyst
Image Analyst 2021-6-17
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

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by