Need help with perimeter of polygon
1 次查看(过去 30 天)
显示 更早的评论
First I need a function that can calculate the perimeter/circumference of a polygon by any given x,y coordinates.
Then I need to make a script that uses that function and loads coordinates from txt file and again calculates the perimeter.
How do i set this up?
4 个评论
Rik
2021-10-8
Copy of the question in case you decide to edit it away for the third time:
Need help with perimeter of polygon
First I need a function that can calculate the perimeter/circumference of a polygon by any given x,y coordinates.
Then I need to make a script that uses that function and loads coordinates from txt file and again calculates the perimeter.
How do i set this up?
回答(2 个)
Rik
2020-9-25
Step by step. Split up your problems in manageable parts.
If you have the coordinates of all corners of your polygon, you can use the Pythagorean theorem to calculate the distance from point to point and sum the results to get the perimeter length.
You script only needs to parse the text file to a list of coordinates. You can then call the function you created.
Which specific step is causing you trouble?
If this isn't homework and you're using R2017b or later you can also use polyshape and perimeter.
0 个评论
Bjorn Gustavsson
2020-9-25
Have a look at the help and documentation of the convhull function.
HTH
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Elementary Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!