Clear Filters
Clear Filters

Organize matrix in a random way

1 view (last 30 days)
eden meirovich
eden meirovich on 28 Apr 2021
Commented: eden meirovich on 28 Apr 2021
Hello, i have a matrix,H which have N rows and n columns.lets say N = 20 and n is 3. i would like to rearange only the rows in H, in a radom way. but keep every element in the say column he was before. so that h(1,:) will be moved to a radom place h(random number,:)
is there a built in function than can do this?
i think i know how to di it by my self, but can find anything bulit in.
thank u!

Accepted Answer

Matt J
Matt J on 28 Apr 2021
N=size(H,1);
H=H(randperm(N),:);
  3 Comments
Matt J
Matt J on 28 Apr 2021
You're welcome, but please Accept-click the answer to indicate that it resolved the question.
eden meirovich
eden meirovich on 28 Apr 2021
sure! thank u a lot Matt

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!