```Path: news.mathworks.com!not-for-mail
From: "Ulrik Nash" <uwn@sam.sdu.dk>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Finding variance of vector, discounting zeros.
Date: Thu, 10 Nov 2011 18:34:27 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <j9h5fj\$rkj\$1@newscl01ah.mathworks.com>
References: <j4vplh\$8rc\$1@newscl01ah.mathworks.com> <j4vqip\$2ar\$1@speranza.aioe.org>
NNTP-Posting-Host: www-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1320950067 28307 172.30.248.48 (10 Nov 2011 18:34:27 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 10 Nov 2011 18:34:27 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:749020

"Nasser M. Abbasi" <nma@12000.org> wrote in message <j4vqip\$2ar\$1@speranza.aioe.org>...
> On 9/16/2011 8:23 AM, Ulrik Nash wrote:
> > Suppose I have a column vector, which includes zeros. How do I find the variance
> >of all the numbers, discounting the zeros?
> >
> > Regards,
> >
> > Ulrik.
>
> i am not good in statistics, but how about simply finding the variance
> of all non-zero elements in the vector?
>
>
> v=[1 2 3 0 4 0 8];
>
> EDU>> var(v(v~=0))
>
> ans =
>
>      7.3000
>
> --Nasser

Suppose that I instead wish to calculate the variance of each column in a matrix, still disregarding zeros, how can I do that without the toolbox?
```