How do I create a set of random numbers with a given set of numbers? Using randi command.

2 visualizaciones (últimos 30 días)
This is my code,
a = [8 5 2 6 9 3 1 4 0 7];
randi(imax,n);
When I run it, there is an error, "Unrecognized function or variable 'imax' ". So I am wondering what is my mistake here?

Respuesta aceptada

madhan ravi
madhan ravi el 22 de Sept. de 2020
Editada: madhan ravi el 22 de Sept. de 2020
a(randi(numel(a), 1, numel(a))) % for unique numbers use randperm()

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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