Create random permutations of an array of decimals or a vector of decimals.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dennis_Pana
el 24 de En. de 2016
Respondida: Walter Roberson
el 24 de En. de 2016
If i have the following vector [0;0.25;0.75;0.5], how i can create 2 or 3 or n permutations? I cannot use randperm, because works only with integers. Thank you in advance!
2 comentarios
John D'Errico
el 24 de En. de 2016
Editada: John D'Errico
el 24 de En. de 2016
Hmm. You cannot use the numbers that randperm will produce as indexes into the vector in question? Gosh, I thought you could do that. So this won't work at all:
v = [0;0.25;0.75;0.5],
ind = randperm(numel(v));
v(ind)
I really thought that would work too. Maybe you should try it? :)
Respuesta aceptada
Walter Roberson
el 24 de En. de 2016
N = 3;
v = [0;0.25;0.75;0.5];
[~, idx] = sort(rand(N, length(v)), 2);
permuted_v = v(idx);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!