Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!news.glorb.com!news2.glorb.com!tr22g12.aset.psu.edu!news.mathforum.org!not-for-mail
From: Torsten Hennig <Torsten.Hennig@umsicht.fhg.de>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Area inside a closed curve
Date: Wed, 04 Aug 2010 02:57:11 EDT
Organization: The Math Forum
Lines: 55
Message-ID: <46043287.53236.1280905062038.JavaMail.root@gallium.mathforum.org>
References: <i3ac8p$qvk$1@fred.mathworks.com>
NNTP-Posting-Host: gallium.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1280905062 10846 144.118.94.39 (4 Aug 2010 06:57:42 GMT)
X-Complaints-To: news@news.mathforum.org
NNTP-Posting-Date: Wed, 4 Aug 2010 06:57:42 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:658890

> Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote
> in message
> <108868415.40482.1280745985673.JavaMail.root@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.