From: Roger Stafford on
"Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <i3anka$di4$1(a)fred.mathworks.com>...
> An alternate formula for the polygon's area is the following. Let X and Y be n by 1 column vectors of the cartesian coordinates of the vertices of a closed polygon. Then its area is (exactly):
>
> area = 1/2*abs(sum(X.*Y([2:end,1],:)-Y.*X([2:end,1],:)));
>
> If the vertices are known to be in counterclockwise order around the polygon, then the 'abs' function is unnecessary. Going clockwise around the polygon would give the negative of the area without the 'abs'.
>
> It should be pointed out that the polygon should never cross over itself as for example in a figure eight. Otherwise some areas would cancel out other areas.
>
> Roger Stafford
- - - - - - - -
Oops! I meant to write:

area = 1/2*abs(sum(X.*Y([2:end,1])-Y.*X([2:end,1])));

Roger Stafford
From: Steve Amphlett on
"Ray Goldman" <kmmansory(a)yahoo.com> wrote in message <i364ls$nh3$1(a)fred.mathworks.com>...
> Hello,
>
> I hope you guys can help, I have a closed curve I need to fine its area. I have two arrays (Flux, Current) that contain the data of the graph. the graph is simply drawn using Plot..
> when they are plotted against each other, they produce something like upside down cone, however, the shape is very irregular and has lots of dents.
> is there any functions that calculates the area inside the closed curve? Thank you so much in advance.

Others have given you code. If you want to know the background to it, look up "Green's Theorem" and "planimeter". All very elegant and satisfying.
From: Torsten Hennig on
> Torsten Hennig <Torsten.Hennig(a)umsicht.fhg.de> wrote
> in message
> <108868415.40482.1280745985673.JavaMail.root(a)gallium.m
> athforum.org>...
> > > Hello,
> > >
> > > I hope you guys can help, I have a closed curve I
> > > need to fine its area. I have two arrays (Flux,
> > > Current) that contain the data of the graph. the
> > > graph is simply drawn using Plot..
> > > when they are plotted against each other, they
> > > produce something like upside down cone, however,
> the
> > > shape is very irregular and has lots of dents.
> > > is there any functions that calculates the area
> > > inside the closed curve? Thank you so much in
> > > advance.
> >
> > If (x_i,y_i) (1<=i<=n) are the points that define
> > the closed curve (with (x_1,y_1)=(x_n,y_n)),
> > an approximation of the enclosed area is given by
> > 0.5*sum_{i=1}^{n-1} 0.5*(x_i+x_(i+1))*(y_(i+1)-y_i)
> -
> > 0.5*sum_{i=1}^{n-1} 0.5*(y_i+y_(i+1))*(x_(i+1)-x_i)
> >
> > This is the discrete form of the well-known
> > formula
> > |A| = int_{A} 1 dA = 1/2 * int_{C} (x dy - y dx)
> > where C is the curve enclosing the area A.
> >
> > Best wishes
> > Torsten.
>
> Hi Torsten
> Thank you for replying, can you please clarify the
> equation more, I'm having problem with this part
> (0.5*sum_{i=1}^{n-1}), what is it and does it relate
> to the rest of the equation.
>
> Thank you.

If you collect terms in the two sums, you get as
a simplified result that |A| is approximately
0.5*sum_{i=1}^{n-1} (x_i*y_(i+1)-x_(i+1)*y_i)
= 0.5*((x_1*y_2-x_2*y_1)+(x_2*y_3-x_3*y_2)+...+
(x_(n-1)*y_n-x_n*y_(n-1)))
which should equal the result if you use
- as Imageanalyst suggested - the polyarea
function in MATLAB.
It is the area inside the polygon formed by the
vertices (x_1,y_1),...(x_n,y_n) where
(x_1,y_1) = (x_n,y_n).

Best wishes
Torsten.