Polyarea for noncontinuous shapes

Using a series of points, I would like to calculate the area the shape creates. For example, the following: x=(-.24 -.29 -.19 -.31 -.14 -.15 -.34 -.03 -.31 -.01 -.23 -.19 -.13 -.09) y=(-.01 -.07 -.06 -.05 -.03 0 .05 .07 .11 .15 .19 .21 .26 .27) doesn't graph as a continuous ellipsoid and as such the polyarea function doesn't work appropriately. I tried converting the points from cart2pol and back using pol2cart but that only creates a continual ellipsoid for shapes where the point (0,0) lies inside. For shapes where (0,0) does not lie inside (such as the example with the points given) this does not work. Can anyone suggest a way to correctly calculate the area of these? Thank you!

댓글 수: 3

Sean de Wolski
Sean de Wolski 2011년 12월 8일
It's not clear what you're after. Perhaps you could post a picture of the expectations (points/shapes etc.)?
In the mean time, I might recommend reading Steven Lord's reply in this old newsreader thread:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/256591
Laura Kloepper
Laura Kloepper 2011년 12월 8일
Ah, thank you for that Sean. I'm now able to reconstruct the curve but my problem of finding the area enclosed by the curve still exists. The final output for the curve according to the tutorial (xb and yb) are both 2xn and (as far as I understand it) polyarea only works with 1xn inputs. Is there a way around this?
Sean de Wolski
Sean de Wolski 2011년 12월 8일
I don't follow on xb/yb being 2xn? They're lists of x/y coordinates right? So why shouldn't they be 1xn or nx1? I think this is a place where picture=='1000words';

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

답변 (2개)

Laura Kloepper
Laura Kloepper 2011년 12월 8일

0 개 추천

When the original points listed are plotted, it looks like this: http://i40.tinypic.com/swz22p.jpg which has x and y values of 1x53 each.
When the curve is calculated with Delaunay triangulation it looks like this: http://i40.tinypic.com/2e5pikw.jpg This is ultimately what I'd like to calculate the area of.
But the xb and yb values are each 2x53, hence why the polyarea function won't work. Ideas?

댓글 수: 2

Sean de Wolski
Sean de Wolski 2011년 12월 8일
Are the rows of xb and yb identical? How were they generated from your above points?
Laura Kloepper
Laura Kloepper 2011년 12월 8일
Yes. They are identical and were generated from the delaunay curve fitting tutorial you suggested. Also, when I run the exact script from the tutorial (#7) it generates 2x192 for both xb and yb.

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

Sean de Wolski
Sean de Wolski 2011년 12월 8일

0 개 추천

So you do want the convex hull! That simplifies it a lot.
x=[-.24 -.29 -.19 -.31 -.14 -.15 -.34 -.03 -.31 -.01 -.23 -.19 -.13 -.09];
y=[-.01 -.07 -.06 -.05 -.03 0 .05 .07 .11 .15 .19 .21 .26 .27];
tri = DelaunayTri(x',y');
[junk, the_area] = convexHull(tri);
Or you can skip the Delaunay triangulation all together and use the second output of convhull:
[junk, the_area] = convhull(x',y');

댓글 수: 1

Laura Kloepper
Laura Kloepper 2011년 12월 8일
Awesome! Thanks so much Sean. You have no idea how much this helps!

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

카테고리

도움말 센터File Exchange에서 Triangulations에 대해 자세히 알아보기

태그

질문:

2011년 12월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by