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 ??
0 个评论
采纳的回答
KSSV
2016-12-6
k = rand(100) ;
ny =size(k,2) ;
shuffle = randsample(1:ny,ny) ;
k_shuffle = k(:,shuffle) ;
更多回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 General Applications 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!