Finding the area of a polygon.
조회 수: 7 (최근 30일)
이전 댓글 표시
Hi I have a set of x and y coordinates which form the corners of a polygon. I need to calculate area manually using the shoelace formula as illustrated below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159453/image.jpeg)
I need to do this way of multiplying to get two vectors using vectorization. I am not sure of how I would write code for this. It needs to be so that if the amount of corners increased or there values their values changed this would be accounted for.
Thanks,
댓글 수: 0
채택된 답변
Sean de Wolski
2014년 3월 25일
편집: Sean de Wolski
2014년 3월 25일
>> edit polyarea
Look at the code, it implements the surveyor's formula that you have.
댓글 수: 0
추가 답변 (1개)
Image Analyst
2014년 3월 25일
Is this homework, where you need to use that? Otherwise, just use the built in polyarea() function.
댓글 수: 2
Image Analyst
2014년 3월 25일
You should have tagged it as homework then, but I did it for you. So, first read this: http://www.mathworks.com/matlabcentral/answers/8626-how-do-i-get-help-on-homework-questions-on-matlab-answers then show how you made some nested for loops to do the multiplication and ask for help. But you need to do something first. We can't just hand over a turnkey homework solution to you.
참고 항목
카테고리
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!