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=407)

wpy6609 2007-06-19 18:03

【求助】产生随机数??
 
问题:根据平均分布在[a,b]内产生mn个随机数,并把这些随机数赋职给变量Pij,其中i=1,2,。。。,m;j=1,2,。。。,n。

求程序

spy1120 2007-06-21 14:26

X=rand(m,n).*(b-a)+a

wpy6609 2007-06-24 18:50

楼上给的程序不对,因为只能产生一个随机数,而我要的是mn个随机数

spy1120 2007-06-25 14:23

谁说产生一个数的?
下面在〔-5,5)之间随机产生5行6列的数
clear;clc
m=5;n=6;
a=-5;b=5;
X=rand(m,n).*(b-a)+a

X =
-0.0345 1.6023 2.2711 2.0274 2.9482 4.7975
3.9977 -1.5803 -1.9071 0.4657 4.5684 -2.2855
3.2163 -2.1027 3.3850 -0.5512 0.2259 -2.4767
1.4491 -1.5881 0.6807 1.9457 3.8014 3.7574
3.1797 0.3408 -1.2959 1.2131 -3.2704 2.3731
>>

wpy6609 2007-06-25 22:45

谢谢,知道了!


所有时间均为北京时间。现在的时间是 04:59

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