MATLAB: What 0 represents in rand function

What rand ('state', 0) is represents. i read in the document, it shows that it is generating random number. Not clear about what state and 0 represents. how can i verify it in matlab?
Also it is mentioned old version follows this way of representation. In new version it is changed. if so how i can represent it in current version. will current version still accept the above line?

Best Answer

See this link http://www.mathworks.com/help/matlab/math/updating-your-random-number-generator-syntax.html which discusses the "discouraged" syntaxes of rand, which includes your example of rand('state',0).
From the documentation:
In earlier versions of MATLABĀ®, you controlled the random number generator used by the rand and randn functions with the 'seed', 'state' or 'twister' inputs...These syntaxes referred to different types of generators, and they will be removed in a future release for the following reasons:
  • The terms 'seed' and 'state' are misleading names for the generators.
  • All of the former generators except 'twister' are flawed.
  • They unnecessarily use different generators for rand and randn.
It goes on to discuss what the intent was behind rand('state',sd), why it was discouraged, and what it should be replaced by.
In your case, the alternative for rand('state',sd) would be rng(sd). It is best to use the recommended alternative as per the note.
You can verify that the original call still does work (though it should be replaced!). In the Command Window type
rand('state',0)
A = rand(100,1);
rand('state',0);
B = rand(100,1);
find((A-B)~=0)
Note that A and B will have the same set of randomly generated numbers, so find((A-B)~=0) will be zero.