Repetition of element in matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Suppose i have a matrix A=[23 17]
I want to proportion element of A in such a way that sum will remains equal to elemental value of A.
E.g 23 can be proportion to 8 8 7 . Similarly 17 can be 7 7 3
Hence final matrix will be B= [8 8 7 7 7 3]
I am trying to use repelem function but it requires equal proportion of elemets.
How to generate B matrix?
댓글 수: 0
채택된 답변
Walter Roberson
2021년 9월 4일
If you are looking for random values, then see https://www.mathworks.com/matlabcentral/answers/327656-conditional-random-number-generation#answer_257296 which has code written by someone who put a lot of thought into making the process "fair"
댓글 수: 2
Walter Roberson
2021년 9월 4일
https://www.mathworks.com/matlabcentral/answers/1446644-repetition-of-elements-in-a-matrix#answer_780764
I already posted complete code.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!