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

 Respuesta aceptada

Jiro Doke
Jiro Doke el 26 de Feb. de 2012

30 votos

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

6 comentarios

N/A
N/A el 24 de Oct. de 2017
briliant !
Farid Khosravikia
Farid Khosravikia el 17 de En. de 2018
Awesome!
A Aftab
A Aftab el 18 de Abr. de 2020
Super!
Mohan Kumar
Mohan Kumar el 26 de Abr. de 2020
brilliant
Sivabalan Selvarajan
Sivabalan Selvarajan el 31 de Mayo de 2020
Worked good !
Ahmad Momeni
Ahmad Momeni el 9 de Nov. de 2020
Perfect!

Iniciar sesión para comentar.

Más respuestas (2)

pavlos
pavlos el 28 de Feb. de 2012

2 votos

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

1 comentario

Jan
Jan el 28 de Feb. de 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.

Iniciar sesión para comentar.

Zeab
Zeab el 7 de Nov. de 2018

1 voto

A simple line of code working great!

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Preguntada:

el 26 de Feb. de 2012

Comentada:

el 9 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by