Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Which ML function for variance?
Date: Tue, 2 Oct 2007 15:04:16 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 16
Message-ID: <fdtmlg$t1j$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-06-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1191337456 29747 172.30.248.36 (2 Oct 2007 15:04:16 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 2 Oct 2007 15:04:16 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1030060
Xref: news.mathworks.com comp.soft-sys.matlab:431017



I have two vectors. The element-by-element differences
represent an error quantity. I want to obtain the variance
(or square root) of these two vectors and I don't see a ML
function that will do this.

Here's what I'm doing right now:

differences = v1(ndx-rng:ndx+rng) - v2(ndx-rng:ndx+rng);
squaredDiffs = differences.^2;
sumSquares = sum(squaredDiffs);
result = sqrt (sumSquares / (length(squaredDiffs)-1) );

Is there a more efficient way to do this? Is there a single
ML function I can call that would do the same thing? 

Thanks.