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

4 次查看(过去 30 天)
Hi, How to permute the columns in a matrix in randomly without changing its size ??

采纳的回答

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

更多回答(1 个)

Daniel Morais
Daniel Morais 2017-3-21
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by