In Matlab I have the following:
n=308;
s=zeros(1,n);
na=8;
ar=rand(1,na);
Now i want to achieve the same in Python, what would be its equivalent? i tried the following
n = 308
s = np.zeros((0,n-1))
print('s:',s)
na = 8
ar = np.random.rand(0,na-1)
print('ar:',ar)
Expected result for 's' is an array or list of zeros ranged between 1 and 308.
After executing in Python, I get the output for 's' is just [ ].
Expected result for 'ar' is an array of Uniformly distributed pseudorandom numbers ranged between 1 and 8, i.e as in matlab, the result is [0.8147, 0.9058, 0.1270, 0.9134, 0.6324, 0.0975, 0.2785, 0.5469].
After executing in Python, I get the output for 'ar' is just [ ].
Aucun commentaire:
Enregistrer un commentaire