mercredi 20 avril 2016

randomly generate the number within a specified range but condition is that two numbers are not same

I want to generate the random number within a specified range but condition is that generated two number is not same. I use following code for generating the random number.

 A=randi(100,1,39)

which will give me a set of 39 number between 1 to 100. it also generate the same number. i.e in following set of number 44 comes two times.

A =

Columns 1 through 25

78    49    44    45    31    51    52    82    80    65    38    82    54    36    94    88    56    63    59    21    31    48    24    85    20

Columns 26 through 39

23    18    23    **44**    32    93    44    19    91    98    **44**    12    26    41

kindly suggest me to generate a random number but any of generated number is not repeat in set of generated number.




Aucun commentaire:

Enregistrer un commentaire