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

 Accepted Answer

Jiro Doke
Jiro Doke on 26 Feb 2012
random_x = x(randperm(size(x, 1)), :)

More Answers (2)

pavlos
pavlos on 28 Feb 2012

2 votes

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

1 Comment

Jan
Jan on 28 Feb 2012
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.

Sign in to comment.

Zeab
Zeab on 7 Nov 2018

1 vote

A simple line of code working great!

Categories

Asked:

on 26 Feb 2012

Commented:

on 9 Nov 2020

Community Treasure Hunt

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

Start Hunting!