From: Jose on
Hello,

I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.

I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
I need the standard deviation without considering zero values.

Thank you very much for your help.
Jose
From: Vince Petaccio on
"Jose " <mylordjose(a)hotmail.com> wrote in message <hhb33c$d0a$1(a)fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose

Asorted=sort(A);
zeroloc=find(A==0);
ANoZeros=Asorted(max(zeroloc)+1:length(Asorted));
StandardDeviation=std(ANoZeros);
From: Dave Berger on
"Vince Petaccio" <vince(a)moberg.com> wrote in message <hhb3o1$nb9$1(a)fred.mathworks.com>...
> "Jose " <mylordjose(a)hotmail.com> wrote in message <hhb33c$d0a$1(a)fred.mathworks.com>...
> > Hello,
> >
> > I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
> >
> > I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> > I need the standard deviation without considering zero values.
> >
> > Thank you very much for your help.
> > Jose
>
> Asorted=sort(A);
> zeroloc=find(A==0);
> ANoZeros=Asorted(max(zeroloc)+1:length(Asorted));
> StandardDeviation=std(ANoZeros);

or
std(A(A~=0))
From: Andy on
"Jose " <mylordjose(a)hotmail.com> wrote in message <hhb33c$d0a$1(a)fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose

% No need to do any sorting:

A=[5, 6, 8, 0, 4,8, 0, 8];
s=std(A(A~=0));
From: Vince Petaccio on
"Jose " <mylordjose(a)hotmail.com> wrote in message <hhb33c$d0a$1(a)fred.mathworks.com>...
> Hello,
>
> I need to get the standar deviation from a vector, but the promem is that inside that vector I have some zero value that can not be included in the calculation.
>
> I mean lets say I have the vector A=[5, 6, 8, 0, 4,8, 0, 8]
> I need the standard deviation without considering zero values.
>
> Thank you very much for your help.
> Jose


^ What they said. :oD