行的随机顺序Matlab [英] Random order of rows Matlab

查看:102
本文介绍了行的随机顺序Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有一个尺寸为100x3的矩阵

Say we have a matrix of size 100x3

您将如何在MATLAB中对行进行随机排序?

How would you shuffle the rows in MATLAB?

推荐答案

要随机排列矩阵的行,可以使用

To shuffle the rows of a matrix, you can use RANDPERM

shuffledArray = orderedArray(randperm(size(orderedArray,1)),:);

randperm将生成一个N随机值的列表并对其进行排序,并返回sort的第二个输出作为结果.

randperm will generate a list of N random values and sort them, returning the second output of sort as result.

这篇关于行的随机顺序Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆