Borrar filtros
Borrar filtros

How do you use randperm on a vector?

9 visualizaciones (últimos 30 días)
lauuser1
lauuser1 el 14 de Feb. de 2016
Comentada: Guillaume el 14 de Feb. de 2016
I have a vector
A = repmat(1:6, [1 4])
and I need to use randperm to randomize it. How would I do that?

Respuesta aceptada

Kristi
Kristi el 14 de Feb. de 2016
A = repmat(1:6, [1 4])
B = A(randperm(24))
  1 comentario
Guillaume
Guillaume el 14 de Feb. de 2016
B = A(randperm(numel(A))
would be a lot better since it will work regardless of the size of A. As a rule avoid hardcoded constants, particularly as it's trivial to obtain the number of elements in A.

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