swap matrix row randomly

40 次查看(过去 30 天)
pavlos
pavlos 2012-2-26
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

采纳的回答

Jiro Doke
Jiro Doke 2012-2-26
random_x = x(randperm(size(x, 1)), :)
  6 个评论

请先登录,再进行评论。

更多回答(2 个)

pavlos
pavlos 2012-2-28
Hello,
Yes, that worked fine.
Thank you.
Best,
Pavlos
  1 个评论
Jan
Jan 2012-2-28
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
A simple line of code working great!

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by