How to generate non repeating random numbers

Hi, I have a matrix of size 270x360 ,what i need to do is generate any random location in that matrix such that all the locations of that matrix are generated at least for once.Is that possible.If so can anybody please help me with it? Thank you, Deepa

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 9 de Ag. de 2015
Editada: Azzi Abdelmalek el 9 de Ag. de 2015
A=zeros(270,360)
The locations of the matrix A are 1:270*360 (using linear indexing)
n=270*360
random_location=randperm(n)
If you want subscript indices ii and jj use ind2sub function
[ii,jj]=ind2sub(size(A),random_location)

3 comentarios

Deepa AS
Deepa AS el 9 de Ag. de 2015
Thank you for your response sir, but how do we get the index values?
Azzi Abdelmalek
Azzi Abdelmalek el 9 de Ag. de 2015
Have you read the answer?
Deepa AS
Deepa AS el 9 de Ag. de 2015
I just noticed ,thank you sir.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Preguntada:

el 9 de Ag. de 2015

Comentada:

el 9 de Ag. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by