Picking a random row of a matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, I have a matrix Y that's nx2. Say in this case n=5. (n can only take the values 3,5 or 8 but I guess that doesn't matter)
Y =
9 2
10 2
9 3
9 4
10 4
I want to randomly choose on of these rows so I can use them as coordinates!
Many thanks,
Phill
댓글 수: 0
채택된 답변
James Tursa
2019년 11월 27일
편집: James Tursa
2019년 11월 27일
k = randi(size(Y,1)); % the random row index
Y(k,:) is the random row
댓글 수: 0
추가 답변 (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!