random selection
이전 댓글 표시
I have a matrix size of 96x249.How can i select 48 rows randomly and store it into a new matrix of 48x249.I have values in matrix as decimal numbers.
채택된 답변
추가 답변 (2개)
Peter Perkins
2011년 11월 1일
1 개 추천
There are a number of ways to do this, including Walter's suggestion. But in addition, if you have access to MATLAB R2011b, there is the slightly simpler
NewMatrix = OldMatrix(randperm(96,48),:);
and if you have access to the Statistics Toolbox in R2011b, there is also
NewMatrix = datasample(OldMatrix,48);
The latter option also allows you to sample with weights, and with replacement. Of course, neither allows you to get the rest of the matrix.
카테고리
도움말 센터 및 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!