[Scilab-users] mean of elements corresponding element is "true"

Samuel Gougeon sgougeon at free.fr
Sat Mar 3 17:49:10 CET 2018


Le 03/03/2018 à 13:15, Rafael Guerra a écrit :
>
> An alternative solution:
>
> n=10;
>
> M=bool2s(rand(n,n)>0.5);/// Boolean to zero-ones matrix/
>
> A=rand(n,n);
>
> x=sum(A.*M,'r')./sum(M,'r');
>

Indeed. This is basically what nanmean()  does, managing in addtition 
cases where no components remain on a range (all "%F").

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180303/9f2e4a6d/attachment.htm>


More information about the users mailing list