Generating random integer from -x to x
3 ビュー (過去 30 日間)
古いコメントを表示
I need to find a way to generate a random integer from -x to x for example -5 to 5
0 件のコメント
採用された回答
その他の回答 (1 件)
per isakson
2014 年 3 月 12 日
編集済み: per isakson
2014 年 3 月 12 日
2*x*rand-x produces uniformly distributed numbers
Doc says: Example 1, Generate values from the uniform distribution on the interval [a, b]:
r = a + (b-a).*rand(100,1);
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!