jpf66
jpf66

Reputation: 119

Use MATLAB to randomly pair two variables

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?

Upvotes: 0

Views: 156

Answers (1)

Andrew
Andrew

Reputation: 1851

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)

Upvotes: 2

Related Questions