Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Which ML function for variance?
Date: Tue, 2 Oct 2007 16:22:09 +0000 (UTC)
Organization: Atlantic Inertial Systems
Lines: 27
Message-ID: <fdtr7h$2q9$1@fred.mathworks.com>
References: <fdtmlg$t1j$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 1191342129 2889 172.30.248.38 (2 Oct 2007 16:22:09 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 2 Oct 2007 16:22:09 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1091020
Xref: news.mathworks.com comp.soft-sys.matlab:431033



"G.A.M. " <x0zero@gmail.com> wrote in message
<fdtmlg$t1j$1@fred.mathworks.com>...
> 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.

std(), var()

you could locate these by opening help (F1) and searching
for variance, or typing 

>> lookfor variance

~Adam