Borrar filtros
Borrar filtros

how to fix a sequence generated using randperm

2 visualizaciones (últimos 30 días)
Foram Sanghavi
Foram Sanghavi el 2 de Jun. de 2018
Comentada: Foram Sanghavi el 2 de Jun. de 2018
I am trying to generate a sequence of numbers using randperm, is there a way I can fix the sequence generated like for example we can use rng for randi.

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Jun. de 2018
randperm() uses rand() internally, so rng() will work.
  3 comentarios
Walter Roberson
Walter Roberson el 2 de Jun. de 2018
>> rng(55)
>> randperm(18,5)
ans =
14 1 4 15 7
>> rng(55)
>> randperm(18,5)
ans =
14 1 4 15 7
Foram Sanghavi
Foram Sanghavi el 2 de Jun. de 2018
Thank you so much, I was not setting the seed in rng, hence was not getting the same answer.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by