フィルターのクリア

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

1 回表示 (過去 30 日間)
Abdulatif Alabdulatif
Abdulatif Alabdulatif 2014 年 4 月 30 日
コメント済み: Matt J 2014 年 4 月 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
Abdulatif Alabdulatif 2014 年 4 月 30 日
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 : )
Matt J
Matt J 2014 年 4 月 30 日
Yes, see the size() command
[numRows,numCols]=size(X);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by