Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
kortas manel
kortas manel le 6 Déc 2016
Commenté : ghali ahmed le 25 Déc 2017
Hi, How to permute the columns in a matrix in randomly without changing its size ??

Réponse acceptée

KSSV
KSSV le 6 Déc 2016
k = rand(100) ;
ny =size(k,2) ;
shuffle = randsample(1:ny,ny) ;
k_shuffle = k(:,shuffle) ;
  2 commentaires
kortas manel
kortas manel le 6 Déc 2016
Thank you this is what i am looking for
ghali ahmed
ghali ahmed le 25 Déc 2017
thank you very much ! :)

Connectez-vous pour commenter.

Plus de réponses (1)

Daniel Morais
Daniel Morais le 21 Mar 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.

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by