Finding the angle of inclination from two end points of a line.

조회 수: 32 (최근 30일)
point1 = [22, 114];
point2 = [693, 233];
x1 = point1(1);
y1 = point1(2);
x2 = point2(1);
y2 = point2(2);
slope = (y2 - y1) ./ (x2 - x1);
angle = atand(slope)
Output
angle = 10.0567
This line has a negative slope. Why am I getting an incorrect answer?
  댓글 수: 3
samundeeswari p
samundeeswari p 2021년 10월 23일
This code works well... Thank you

댓글을 달려면 로그인하십시오.

채택된 답변

Andrei Bobrov
Andrei Bobrov 2017년 6월 19일
point1 = [22, -114];
point2 = [693, -233];
x1 = point1(1);
y1 = point1(2);
x2 = point2(1);
y2 = point2(2);
slope = (y2 - y1) ./ (x2 - x1)
angle = atand(slope)

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by