From: Jose on
Thanks a lot!
From: Jose on
Thanks a lot!
From: Neil 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
Maybe logical addressing might be an alternative.
grunk = std(A(A~=0));

m-lint always seem to tell me logical addressing is faster than find.
I'd have to say though, that if you can, change your flag value: using say, nan rather than 0 would be clearer as 0 is a valid numerical value.
grunk = std(A(~isnan(A));