I have to write a Pseudo random number generator with matlab, but I don't know how to start.
This is the equation:
Xk+1 = [711*Xk + 37]mod10000 and xo = 1234
I know that I need to write a loop statement, but I don't know how to do it. Also, what is "mod" and is there a statement in matlab to find the it?
This is what I've done, but it doesn't work
m = 1000;
a = 711;
b = 37;
x(0) = 1234;
for k = 0:100
x(k+1) = mod(a*x(k) + b,m);
end
Thanks in advance
Comments
So, in your code:
m = 1000;
a = 711;
b = 37;
x([b]1[/b]) = 1234;
for k = [b]1[/b]:100
x(k+1) = mod(a*x(k) + b,m);
end