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$>
References: <gmq041$2g2$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1234211462 3864 (9 Feb 2009 20:31:02 GMT)
NNTP-Posting-Date: Mon, 9 Feb 2009 20:31:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:517163

"rocky99 Therminator" <> wrote in message <gmq041$2g2$>...
> 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