Matlab中的随机矩阵元素 [英] shuffle matrix element in matlab
本文介绍了Matlab中的随机矩阵元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个martix,想对其元素进行洗牌.
I have a martix and want to shuffle element of it .
x=[1 2 5 4 6 ]
洗牌后(类似这样)
x=[2 4 6 5 1]
matlab是否具有功能? 在php array_shuffle 中执行此操作.
is matlab has function for it ? in php array_shuffle do this.
推荐答案
-
使用
randperm
idx = randperm(length(x));
使用索引获取混洗后的向量
use indices to obtain shuffled vector
xperm = x(idx);
这篇关于Matlab中的随机矩阵元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文