Randomly generated numbers do not change themselves with each iteration
1 view (last 30 days)
I have a long code and at the end of it I reach a maximum values using tons of randomly generated numbers and distribution method. Now, I want to put this whole code into for loop and for each iteration, since those random number generation functions will generate different numbers in each iterations, I want to obtain different maximum values. I simply added a "for l=1:4" at the beginning and at the end, I added Maxx(l)=max(Difference).There, "difference" is (1000,1) vector for 1000 randomly generated numbers. Instead of obtaining 4 different max result caused from different random number generation, I got same result every iteration. What might be the reason and how can I solve this? Thank you for your help.
the cyclist on 8 Jun 2022
Can you post your code? This miniature version of what you described seems to work.
for l = 1:4
difference = rand(1000,1);
maxx(l) = max(difference);
Or maybe it only seemed that your values were not different, because you did not display with enough digits?