How can I choose a random row from a specific multidimensional array?

1 次查看(过去 30 天)
Hi,
I have a multidimensional array X=(50,9), and I want to choose a random row of 50 exist rows in an array.
First row in this array is just scalar numbering from 1 up to 50, I do not know if this can help to pick a random row based on the first row value or not!
Thanks in advance!

采纳的回答

Matt J
Matt J 2014-4-30
randomRow=X(randi(50),:);
  2 个评论
Abdulatif Alabdulatif
That was so quick : )
Thanks a lot.
Is it possible to replace the length of the array rows (50) with flexible statement to specify the number of rows in any array?
I just ask to generalise the answer rather than specified a specific value
Thanks again : )

请先登录,再进行评论。

更多回答(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