if you always want the same value from a random generator check the following link
otherwise suppose you have 10 iteration and want to store 10 different random numbers in B then
B = zeros(1,10);
for i =1:10
z = rand(1);
A = [z z z z z];%you can use A = repmat(z,1,5);
B(i) = z;
end