Borrar filtros
Borrar filtros

How to permute the columns in a matrix in random way?

4 visualizaciones (últimos 30 días)
kortas manel
kortas manel el 6 de Dic. de 2016
Comentada: ghali ahmed el 25 de Dic. de 2017
Hi, How to permute the columns in a matrix in randomly without changing its size ??

Respuesta aceptada

KSSV
KSSV el 6 de Dic. de 2016
k = rand(100) ;
ny =size(k,2) ;
shuffle = randsample(1:ny,ny) ;
k_shuffle = k(:,shuffle) ;
  2 comentarios
kortas manel
kortas manel el 6 de Dic. de 2016
Thank you this is what i am looking for
ghali ahmed
ghali ahmed el 25 de Dic. de 2017
thank you very much ! :)

Iniciar sesión para comentar.

Más respuestas (1)

Daniel Morais
Daniel Morais el 21 de Mzo. de 2017
Utilize x = x( : , randperm(c)), onde x é a matriz e c o número de colunas de x. O mesmo vale para a permutação de linhas: x = x( randperm(l) , : ) onde l é o número de linhas.

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