I have x,y value and they form a polyline ,how can i find the slope of each line without putting any manual efforts?

조회 수: 4 (최근 30일)
Sometimes the number of line forming from the data is not easy to interpret.I have to automate the process so that it can pick the number of polyline the data is forming and slope of each line.

답변 (1개)

DGM
DGM 2022년 12월 6일
If you have a polyline and want the slope or angle of each segment, consider the simple example:
% vertices of a polyline (this case is a closed polygon, but w/e)
x = [0 1 0.5 0];
y = [0 0 sqrt(3)/2 0];
% segment slope and angle
slope = diff(y)./diff(x)
slope = 1×3
0 -1.7321 1.7321
theta = atan2d(diff(y),diff(x))
theta = 1×3
0 120.0000 -120.0000
% plot it
plot(x,y)
  댓글 수: 2
TAPAS
TAPAS 2022년 12월 6일
이동: Voss 2022년 12월 7일
This a sample data.I just want to find out how the data can be best fitted and and how many best fitted line possible.
TAPAS
TAPAS 2022년 12월 7일
이동: Voss 2022년 12월 7일
Basically all I need to know is how to segment wise fit data?

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by