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

 Risposta accettata

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

6 Commenti

N/A
N/A il 24 Ott 2017
briliant !
Farid Khosravikia
Farid Khosravikia il 17 Gen 2018
Awesome!
A Aftab
A Aftab il 18 Apr 2020
Super!
Mohan Kumar
Mohan Kumar il 26 Apr 2020
brilliant
Worked good !
Ahmad Momeni
Ahmad Momeni il 9 Nov 2020
Perfect!

Accedi per commentare.

Più risposte (2)

pavlos
pavlos il 28 Feb 2012

2 voti

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

1 Commento

Jan
Jan il 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.

Accedi per commentare.

Zeab
Zeab il 7 Nov 2018

1 voto

A simple line of code working great!

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by