Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
To get a random number
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Muruganandham Subramanian
el 18 de En. de 2012
Cerrada: MATLAB Answer Bot
el 20 de Ag. de 2021
Hi,
Am having a incremental column matrix like, e.g. for 1st iteration, it is 100*1(double), then for 2nd iteration iteration, it will be 100*2(double), etc.. Form this, for 1st iteration, i need to get a random no (single data only). from 1st column of matrix and for 2nd iteration, i have to get a random no. from 2nd column of matrix only.
Thank you in advance!!@!!
1 comentario
Michael
el 18 de En. de 2012
Maybe I misunderstand but to me this question appears contradictory. How is a number random if it depends on your column as an input?
Respuestas (1)
Wayne King
el 18 de En. de 2012
You can use
x = randperm(100);
randomindex = x(1);
Then, use that index to choose an element from the appropriate column, say your data matrix is X
X(randomindex,1) %choose from first column
X(randomindex,2) %choose from 2nd column
7 comentarios
Walter Roberson
el 20 de En. de 2012
Sorry, the references to size(X,2) should have been size(X,1)
rchoices = randperm(size(X,1));
randchoice = X(rchoices(1),IterationNumber);
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!