Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

shuffle matrix element in matlab

I have a martix and want to shuffle element of it .

x=[1 2 5 4 6 ]

after shuffle(something like this)

x=[2 4 6 5 1]    

is matlab has function for it ? in php array_shuffle do this.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  1. obtain shuffled indices using randperm

    idx = randperm(length(x));
    
  2. use indices to obtain shuffled vector

    xperm = x(idx);


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...