n人中m人が当選するくじ
Posted feedbacks - Matlab
やっていることはMathematica版と同じですね。
出力例:
>> lot(100, 10)
ans =
80 42 71 97 51 4 81 94 2 92
1 2 3 4 | function x = lot(n, m)
A = randperm(n);
x = A(1:m);
end
|
もうすこし調べたら、そのものずばりの関数がありました。がっかり。
出力例:
>> randsample(100,10)
ans =
96
6
71
46
81
56
34
22
80
88
1 | randsample(n,m)
|



にしお
#3360()
Rating0/0=0.00
[ reply ]