>> x=rand(1,10);y=sum(x);r=x/y%r就是随机数和为一,且都是(0,1)内的数
r =
Columns 1 through 7
0.1623 0.0228 0.1636 0.1133 0.0175 0.0499 0.0980
Columns 8 through 10
0.1716 0.1729 0.0282
>> sum(r)
ans =
1.0000
>>
x=rand(1,3);y=sum(x);r=x/y