Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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!

Respuesta aceptada

Matt J
Matt J el 30 de Abr. de 2014
randomRow=X(randi(50),:);
  2 comentarios
Abdulatif Alabdulatif
Abdulatif Alabdulatif el 30 de Abr. de 2014
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 el 30 de Abr. de 2014
Yes, see the size() command
[numRows,numCols]=size(X);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by