MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   Matlab中有没有一种方法可以使用伪数字生成器来生成特定范围内的数字? (https://www.labfans.com/bbs/showthread.php?t=23087)

poster 2019-12-10 20:30

Matlab中有没有一种方法可以使用伪数字生成器来生成特定范围内的数字?
 
例如:

round(7*rand(1,5)) 生成1到7之间的5个数字是否有办法生成5到7之间的5个随机数?还是那个的抽象?



[B]回答:[/B]

更普遍:

minInt = 5; maxInt = 7; numInts = 10; r = randi([minInt, maxInt],[1,numInts]) r = 6 7 7 7 6 5 5 5 7 5

[url=https://stackoverflow.com/questions/2152334]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 15:40

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.