MATLAB: How to generate just one random number in every iteration of for loop

for looprandom

I need to generate just one random number in every iterations.
For i=1:10
x(i)=rand(1)
end
%For example when i=4 (x(4)), this code generate 4 random x which is not my favorite i want just another random x

Best Answer

Your storing each random created in each loop, if you only want one just do
x = rand (1);