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.

 Accepted Answer

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

More Answers (0)

Categories

Asked:

on 22 Nov 2021

Commented:

on 22 Nov 2021

Community Treasure Hunt

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

Start Hunting!