0

I am looking to use MATLAB to randomly assign numbers to a list of variables. The variables represent video clips being used in an experiment. I want to randomize the order of the clips, so I want to pair each clip with, for example, numbers 1-15, without repetition.

Any ideas?

Termininja
  • 6,620
  • 12
  • 48
  • 49
jpf66
  • 119
  • 5
  • possible duplicate of [Generate a random number in a certain range in MATLAB](http://stackoverflow.com/questions/5077800/generate-a-random-number-in-a-certain-range-in-matlab) – Ander Biguri Apr 07 '15 at 22:48
  • 2
    @AnderBiguri I think the "without repetition" bit indicates `randperm` instead. – beaker Apr 07 '15 at 22:49
  • @beaker you are right. Most likely duplicate also. Flag it if possible, or answer it else. – Ander Biguri Apr 07 '15 at 22:50

1 Answers1

2

If you put your clips into an array, you can use randperm to shuffle them. For example:

clips = [clip1, clip2, ..., clip15]
shuffle = randperm(length(clips))
randomized_clips = clips(shuffle)
Andrew
  • 1,839
  • 14
  • 25