This is my code :
d=1
p=1
Number_Included = [ 3 7 2 ]
while p<=3
r(d:(d+Number_Included(p)-1)) = rand(1, Number_Included(p));
d=numel(r)+1
p=p+1;
end
the purpose is to generate 3 random numbers , then 7 random numbers, then 2 random numbers in the vector r , thus vector r is supposed to be of the dimension 1*12
1st run gives a vector r 1*12
2nd run, the dimensions of r change to 1*21!
I don't understand why thisis happening, could someone explain to me please, and how do I make sure that the dimensions stay 1*12( the desired) ???
I've notices that this problem does not happen when I clear the workspace
Best Answer