Picking a random row of a matrix

1 Ansicht (letzte 30 Tage)
Phillip Smith
Phillip Smith am 27 Nov. 2019
Bearbeitet: James Tursa am 27 Nov. 2019
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

Akzeptierte Antwort

James Tursa
James Tursa am 27 Nov. 2019
Bearbeitet: James Tursa am 27 Nov. 2019
k = randi(size(Y,1)); % the random row index
Y(k,:) is the random row

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by