Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to select a randomly from the matrices?

1 回表示 (過去 30 日間)
singh
singh 2015 年 3 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have 7 matrices every time, but I do not know how many rows there are in the matrices because rows are randomly inserted into the matrices. I want to choose one row in each of the 7 matrices randomly every time.
Thanks in advance

回答 (1 件)

James Tursa
James Tursa 2015 年 3 月 26 日
To select a random row from a matrix:
the_matrix = your matrix
the_random_row = the_matrix(randi(size(the_matrix,1)),:);
  2 件のコメント
singh
singh 2015 年 3 月 27 日
size of matrix is not equal and after the every execution size of matrix is not same with previous matrix
Image Analyst
Image Analyst 2015 年 3 月 27 日
I don't see that that matters. Please give an example. Are your 7 matrices in a cell array, with 7 cells and one matrix in each cell? If so, use Stephen's answer. If they're separate matrices with separate unique names, use James's Answer. Otherwise, please give a sample of what form your data is in, and an example of the output you would like to get.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by