how to obtain random vector from the defined matrix

suppose, for c matrix c=[1 2 3; 3 4 5;6 7 8;9 10 11;12 13 14;15 16 17];
randomly i have to select any row vector.

 채택된 답변

KSSV
KSSV 2021년 11월 22일
c=[1 2 3; 3 4 5;6 7 8;9 10 11;12 13 14;15 16 17];
[m,n] = size(c)
m = 6
n = 3
idx = randsample(m,1)
idx = 3
iwant = c(idx,:)
iwant = 1×3
6 7 8

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2021년 11월 22일

댓글:

2021년 11월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by