Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Center of gravity of discrete graph
Date: Mon, 9 Feb 2009 20:31:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 7
Message-ID: <gmq3q6$3oo$1@fred.mathworks.com>
References: <gmq041$2g2$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1234211462 3864 172.30.248.38 (9 Feb 2009 20:31:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 Feb 2009 20:31:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:517163

"rocky99 Therminator" <ronenk@mail.com> wrote in message <gmq041$2g2$1@fred.mathworks.com>...
> I'd like to find the center of gravity of a discrete graph. I have the vector (1x200) of the values of the x-axis and the vector (1x200) of the values of the y-axis. (Y is a spectrum and X is a frequency). I need the frequency (x-value) of the center of gravity of this graph.
> Any help would be highly appreciated. Thanks

  What do you mean here by the "center of gravity"?  If each point is considered to have a weight of one, then the graph's center of gravity would have an x-value of mean(x), which is totally independent of the y-values.  Perhaps you mean to have the "center of gravity" of the x-values weighted by the corresponding y-values.  Then it would be mean(x.*y)/mean(y).  It all depends on what meaning you have in mind for a "center of gravity."

Roger Stafford