Filter löschen
Filter löschen

swap matrix row randomly

65 Ansichten (letzte 30 Tage)
pavlos
pavlos am 26 Feb. 2012
Kommentiert: Ahmad Momeni am 9 Nov. 2020
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

Akzeptierte Antwort

Jiro Doke
Jiro Doke am 26 Feb. 2012
random_x = x(randperm(size(x, 1)), :)
  6 Kommentare
Sivabalan Selvarajan
Sivabalan Selvarajan am 31 Mai 2020
Worked good !
Ahmad Momeni
Ahmad Momeni am 9 Nov. 2020
Perfect!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (2)

pavlos
pavlos am 28 Feb. 2012
Hello,
Yes, that worked fine.
Thank you.
Best,
Pavlos
  1 Kommentar
Jan
Jan am 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.

Melden Sie sich an, um zu kommentieren.


Zeab
Zeab am 7 Nov. 2018
A simple line of code working great!

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by