How do I find the mean of a binary set for each value of no.1 to7
조회 수: 2 (최근 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에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!