random number with fixed summation
이전 댓글 표시
I randomly generated the matrix f1; where R is 8 and T is 11. In the following we have f1.
The summation of each column should have a fixed value k, for example k=4. I found the "randfixedsum" function that perfectly generates random number with fixed summation. But the elements are not zero and 1. Could you please help me to change f1 to a matrix that the summation of each column is exactly k.
f1 =
1 0 1 0 0 0 0 1 1 0 0
1 0 0 0 0 1 1 0 1 0 0
1 0 0 1 1 1 0 0 0 0 0
1 0 1 1 0 0 1 1 1 1 1
1 1 0 1 0 0 0 1 1 1 0
0 1 1 0 1 0 1 0 1 1 0
0 1 1 0 0 0 0 1 1 0 0
0 1 1 1 1 0 1 0 1 1 0
채택된 답변
추가 답변 (1개)
Walter Roberson
2016년 11월 14일
0 개 추천
There are multiple ways to handle this, but the easiest way is just to round() the numbers.
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!