Borrar filtros
Borrar filtros

How can i randomly move the values of a vector

1 visualización (últimos 30 días)
zahid
zahid el 23 de Jul. de 2015
Respondida: Thorsten el 23 de Jul. de 2015
Hi everyone.
Suppose i have a column vector X=[1;2;5;7;8].Now i want randomly arrangement of the values of this vector.For example X1=[2,7,8,1,5] is one of such random arrangement.My purpose is to randomly movement of this vector values and then add it to another vector say Y in one of my simulation experiment.
THANKS WITH BEST WISHES

Respuesta aceptada

Manolis Michailidis
Manolis Michailidis el 23 de Jul. de 2015
  1 comentario
Manolis Michailidis
Manolis Michailidis el 23 de Jul. de 2015
sorry now i took a better look here try this
X=[1;2;5;7;8];
n=length(X);
y = datasample(X,n,'Replace',false)

Iniciar sesión para comentar.

Más respuestas (1)

Thorsten
Thorsten el 23 de Jul. de 2015
X = X(randperm(numel(X));

Categorías

Más información sobre Programming 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