How do I sample a random value from a matrix?
조회 수: 4 (최근 30일)
이전 댓글 표시
Let's say I have a random matrix:
A = rand(10,4)
How can I sample a random value from this matrix (without replacement)? Essentially how can I perform a randsample but for a matrix instead of a vector?
댓글 수: 0
채택된 답변
Akira Agata
2018년 5월 2일
If you want to obtain k samples randomly from A, the following will do that.
ind = randperm(numel(A),k);
output = A(ind);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 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!