Repeated Permutation of the same numbers
Show older comments
Hi everyone,
Say I have an array a of 3 numbers (or alternatively of 4 or 5 or..):
a = [0.21 0.018 0.34];
I want to create an array b, which only contains these numbers, however in random order, though each of the numbers should appear the same number of times. For instance if b is [30,1], I would want each of the three numbers to appear 10 times. I know the randperm function, but it seems to me that using randperm is not so straightforward for this task?
Many thanks
Accepted Answer
More Answers (1)
John D'Errico
on 20 Dec 2016
2 votes
Surely this is no harder than creating a new vector, that has the numbers repeated as often as you wish, then randomly permuting it.
Categories
Find more on Programming 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!