MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [讨论]随机数问题 (https://www.labfans.com/bbs/showthread.php?t=5244)

hippo613 2008-11-09 15:02

[讨论]随机数问题
 
假如我通过rand()函数产生了(0,1)间的随机数,然后我使用以下命令:
for i=1:256
K(i)=round(255*rand())+1 %产生【1,256】间的随机数
end

请问使用什么方法能保证K向量中的256个数为1到256的随机数,没有任一一个重复?

slgu 2008-11-10 09:11

回复: [讨论]随机数问题
 
randperm(256)

wykb520 2008-12-02 15:40

回复: [讨论]随机数问题
 
RAND函数什么意思啊??/我昨天就在想这个因为我看一个程序就有这个啊~!


所有时间均为北京时间。现在的时间是 09:50

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