I have x,y value and they form a polyline ,how can i find the slope of each line without putting any manual efforts?
1 次查看(过去 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.
0 个评论
回答(1 个)
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)
theta = atan2d(diff(y),diff(x))
% plot it
plot(x,y)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!