picking a random number in a range
2 次查看(过去 30 天)
显示 更早的评论
hello i have a problem
I can explain this problem as follows;
I want to randomly pick a number between 1 and 69 points. I want the selected number to change every time I run it.
this is my cod; cpoint=unidrnd(69-1);
but this code gives error. How can I do it
Thanks advance.
0 个评论
回答(1 个)
Steven Lord
2022-5-18
Do you want a random integer value or just any old number between 1 and 69?
The next time you draw a random number, are you going to want to exclude the previously drawn number (like if you're simulating a lottery drawing, where once a numbered ball is drawn it cannot be drawn again)?
Take a look at the randi (random integers with replacement), randperm (random integers without replacement), or rand (random numbers) functions.
另请参阅
类别
在 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!