필터 지우기
필터 지우기

swap matrix row randomly

조회 수: 65 (최근 30일)
pavlos
pavlos 2012년 2월 26일
댓글: Ahmad Momeni 2020년 11월 9일
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
Sivabalan Selvarajan
Sivabalan Selvarajan 2020년 5월 31일
Worked good !
Ahmad Momeni
Ahmad Momeni 2020년 11월 9일
Perfect!

댓글을 달려면 로그인하십시오.

추가 답변 (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