swap matrix row randomly

Hello,
I have a 10x20 matrix and I`d like to change the rows randomly. For example, the 1st row will become, let`s say, the 9th, the 2nd will become the 5th, etc.
Any help?
Thank you.
Best,
Pavlos

 采纳的回答

random_x = x(randperm(size(x, 1)), :)

更多回答(2 个)

pavlos
pavlos 2012-2-28

2 个投票

Hello,
Yes, that worked fine.
Thank you.
Best,
Pavlos

1 个评论

Please post a comment to an answer in the comment section for the answer. If an answer solves youzr problem, you can "accept" it to show, that no further assistence is required.

请先登录,再进行评论。

Zeab
Zeab 2018-11-7

1 个投票

A simple line of code working great!

类别

帮助中心File 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