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

Rafael Guerra jrafaelbguerra at hotmail.com
Sun Mar 4 11:34:17 CET 2018


Hermes,

With your solution all false elements (zeros) get averaged with the true ones.
The averaging should be done only over the true-entries.

Regards,
Rafael 

-----Original Message-----
From: users [mailto:users-bounces at lists.scilab.org] On Behalf Of Hermes
Sent: Sunday, March 04, 2018 10:10 AM
To: users at lists.scilab.org
Subject: Re: [Scilab-users] mean of elements corresponding element is "true"

how about this way:

n=10;
boolean_M=rand(n,n)>0.5;
disp(boolean_M)
A=rand(n,n);
disp(A);
x_V=mean(boolean_M.*A,'r')
disp(x_V)

Hermes



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
users at lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users



More information about the users mailing list