Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: random numbers
Date: Wed, 17 Jun 2009 11:01:02 +0000 (UTC)
Organization: University of Oldenburg
Lines: 22
Message-ID: <h1aide$bek$1@fred.mathworks.com>
References: <h1abg5$t3k$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245236462 11732 172.30.248.35 (17 Jun 2009 11:01:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 17 Jun 2009 11:01:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1337500
Xref: news.mathworks.com comp.soft-sys.matlab:548227


you can something like this

function [Msgsize] = sizetext(number,key)

if ~isemptey(key)
    rand('state',key)
endif
number = 300 * 15;
Msgsize= round(rand(floor(number),1));
Msgsize= randintrlv(Msgsize);

by using the rand('state',number) command, you can set the generator to a certain state and thus get the same sequence of random numbers.

simply try in the command line

rand('state',1000),rand,rand

rand('state',1000),rand,rand('state',1000), rand

and see the difference!

doc rand gives more information