Borrar filtros
Borrar filtros

random number generating problems

1 visualización (últimos 30 días)
alexaa1989
alexaa1989 el 19 de Ag. de 2014
Comentada: alexaa1989 el 21 de Ag. de 2014
hi everyone I have written an algorithm in which there is a part that has to produce random numbers like this:
a=randi(10,1,4)
b=randi(10,1,4)
c=randi(10,1,4)
I need it to produce different sets of numbers everytime I run the algorithm but it uses the same sets of numbers everytime
can anyone help?

Respuestas (1)

Guillaume
Guillaume el 19 de Ag. de 2014
In all likelyhood, you're seeding the random number generator with a fixed seed somewhere before calling randi.
Look for a rng(...) instruction and remove it, or insert a rng('shuffle') before calling randi. rng('shuffle') seeds the generator with the current time.
  2 comentarios
Iain
Iain el 19 de Ag. de 2014
Editada: Iain el 19 de Ag. de 2014
If you aren't setting the random number generator with ANY seed, try ensuring that you provide one based on say, the time of day.
alexaa1989
alexaa1989 el 21 de Ag. de 2014
it isn't working with rng and now it is producing not feasible solutions

Iniciar sesión para comentar.

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