Generating random integer between negative and positive range
15 次查看(过去 30 天)
显示 更早的评论
I'm trying to generate a random integer in the range of -5 and +5 using round and rand functions. I'm able to generate a random integer however it always returns a negative value and a zero and not in the expected range.
Obviously the easiest solution to this would be:
round(unifrnd(-5,5));
But I have to use rand function specifically along with round to produce this random number.
I would very much appreciate any advice and help.
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Random Number Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!