Making combinations using random number generators
古いコメントを表示
Hello,
I have this vector
x0 = [1;88;88;2;2;2;2;2;-88;2]
Right now I change the values in this vector manually making combinations, I am looking for a random number generator which will generate combinations of numbers on these 10 slots, like a combination of 10 numbers from 0 till infinity, numbers can be decimals or integers as well or a combination of both
x0 = [x1;x2;x3;x4;x5;x6;x7;x8;x9;x10]
Does anyone knows how it can be done?
I have to use this vector elsewhere in the code...
2 件のコメント
Rafael Hernandez-Walls
2020 年 8 月 28 日
In general, you can generate N random numbers in the interval (a,b) with the formula:
r = a + (b-a).*rand(N,1)
Chris Dan
2020 年 8 月 28 日
採用された回答
その他の回答 (1 件)
Steven Lord
2020 年 8 月 28 日
0 投票
If you want to draw with replacement use randi to generate numbers between 1 and the numel of the array you want to sample. Use those as linear indices into the array.
If you want to draw without replacement use randperm to generate the linear indices.
カテゴリ
ヘルプ センター および File Exchange で Random Number Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!