lundi 2 mai 2016

How to randomly fill a 1x5 array with the numbers from 1 to 5 without repeating a number?

I'm looking to fill a 1x5 array with the numbers from 1 to 5, but I don't want to repeat a number.

I've tried this, which allows numbers to repeat:

r = randi([1,5],5,1)

What I'm looking for is something that will generate ex. [5 2 3 1 4] randomly. Is there a function in Matlab that will allow me to do so?




Aucun commentaire:

Enregistrer un commentaire