Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Restoring the state of random generator

$
0
0
Right.
So I did according to the above method:
rng(0);
for i = 1:2,
     msg = randint(n,L);
     noise = randn(m*k);
end

for trial = 3, %continue from the crashing point
....
     msg = randint(n,L);
     noise = randn(m*k);
....
end
BUT, to my surprise the output msg generated above at trial=3 differs from the msg at trial=3 if generated continuously from the beginning i.e.:
rng(0);
for i = 1:3,
     msg = randint(n,L);
     noise = randn(m*k);
end
In the lines "...." above I am using LDPC encoder and decoder. Does that change the state of rng? If so, is there any way to know how many random numbers are generated at each call of the decode/encode function?
I am guessing that the two lines of "randint" and "randn" are not the only random generations in my code.

Thanks,
Elnaz

Viewing all articles
Browse latest Browse all 19628

Trending Articles