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

5 ビュー (過去 30 日間)
Ahmed Galal
Ahmed Galal 2021 年 6 月 17 日
回答済み: Image Analyst 2021 年 6 月 17 日
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 Center および File ExchangeDynamic System Models についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by