Need help with perimeter of polygon

1 view (last 30 days)
Simen Magnesen
Simen Magnesen on 25 Sep 2020
Commented: Rik on 8 Oct 2021
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 Comments
Rena Berman
Rena Berman on 8 Oct 2020
(Answers Dev) Restored edit
Rik
Rik on 8 Oct 2021
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?

Sign in to comment.

Answers (2)

Rik
Rik on 25 Sep 2020
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.

Bjorn Gustavsson
Bjorn Gustavsson on 25 Sep 2020
Have a look at the help and documentation of the convhull function.
HTH

Categories

Find more on Elementary Polygons in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!