How do I find the mean of a binary set for each value of no.1 to7
1 view (last 30 days)
Show older comments
I have a vector row of 5,000 random no.s 1 to 7. I have a vector row of 5,000 1's and 0's as a second vector row. (This represents 5,000 tirials, where every time the random number was > 4, the machine chose 1, otherwise 0). I have put both vectors together in a matrix/array with the values on top row and the binaries on the second row. I have to calcualte the mean of the responses for each of the values. How do I do this please? I am beginner level and need my variables spelled out, to understand them. I think I use accumarray and mean but not sure how to compile the coding.
3 Comments
TADA
on 19 Jan 2020
how 'double' generates a 1
What image analyst did there was to generate a logical vector which determines when the value is greater than 4:
b = topRow > 4
b =
0 1 0 0 0 0 0 1 0 1
Next this binary vector was converted to an array of double precision numbers by sending it to the double function
bottomrow = double(b);
Or in a single line of code as image analyst did
Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!