Random Number Generator

Hello All,
I have been charged with coming up with a way to raffle an iPad2 at a charity event. The raffle participants are all members of the non-profit with member id#'s. Instead of putting paper in a bowl I thought about using a random number generator to produce the winning member id. I thought that Mat-Lab would be a useful tool for doing this. Any thoughts??

 採用された回答

Paulo Silva
Paulo Silva 2011 年 9 月 1 日

0 投票

RandStream.setDefaultStream(RandStream('mt19937ar','seed',sum(100*clock)));
n=10; %number of ids
randi([1 n])

2 件のコメント

Christopher
Christopher 2011 年 9 月 1 日
Thank you Paulo. There are ~130 different 5-digit id#'s. In this case my n=130. Do I need to code the id#s as integers.
ID 1234556 =1
ID 7891011 =2
Then I would know which ID won the raffle. Is the about right?
Paulo Silva
Paulo Silva 2011 年 9 月 1 日
That would do it but it's too much work and I can't think any other way besides getting another set of consecutive IDs for each participant.

サインインしてコメントする。

その他の回答 (1 件)

カテゴリ

ヘルプ センター および File ExchangeRandom Number Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by