Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
Hi, How to permute the columns in a matrix in randomly without changing its size ??

Risposta accettata

KSSV
KSSV il 6 Dic 2016
k = rand(100) ;
ny =size(k,2) ;
shuffle = randsample(1:ny,ny) ;
k_shuffle = k(:,shuffle) ;

Più risposte (1)

Daniel Morais
Daniel Morais il 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.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by