How do I find the mean of a binary set for each value of no.1 to7
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
TADA
2020-1-19
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!