Picking a random row of a matrix

1 次查看(过去 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

采纳的回答

James Tursa
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 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by