MATLAB:如何矩阵的随机洗牌列 [英] Matlab: How to random shuffle columns of matrix
本文介绍了MATLAB:如何矩阵的随机洗牌列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样一个矩阵:
A=
4 7 8 9
3 3 5 7
6 4 8 6
和希望随机洗牌列并做到这一点是这样的:
and wants to random shuffle columns and do it something like:
A=
8 4 9 7
5 3 7 3
8 6 6 4
没有任何人有任何想法?
does anyone have any idea?
推荐答案
您可以使用洗牌索引列:
You can shuffle columns using indexing:
A(:,[3 1 4 2])
如果你想随意去做,你可以创建一个随机排列:
If you want to do it randomly, you can create a random permutation:
A(:,randperm(size(A,2)));
这篇关于MATLAB:如何矩阵的随机洗牌列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文