下面编了一个用matlab产生(a,b)上均匀随机数的小程序,当我赋值a=1,b=2,n=1000时,前100个数是正常的 但是之后全是0了 肿么回事? 哪里出问题了?
程序:
function t=uni(a,b,n)
%generate the numbers fitted u(a,b)
t=zeros(n,1);
%generate a vector to store the numbers
for k=1:100;
t(k)=(b-a)*rand()+a;
%to generate the numbers that fit my conditions
end


雷达卡




京公网安备 11010802022788号







