Matlab

Moderators: None (Apply to moderate this forum)
Number of threads: 1084
Number of posts: 1765

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
confirm rand Posted by mloone01 on 11 Dec 2009 at 4:44 AM
Hi,
I am using Matlab version 6.1.
I am using the Rand function to generate random numbers but would like to clarify a number of things.
Is RAND based on the CPU Clock cycle?
Also, if I use
rand('seed',fix(100*(sum(clock))));
does this ensure my seed is changed every time?

Thanks
Report
Re: confirm rand Posted by jjasso5 on 12 Dec 2009 at 4:12 PM
I guess yes, the random numbers have something to do with the internal clock.

Besides, this is taken from the on-line help for version 7.0.1
(sorry, I don't have your version)

Return RAND to its default initial state.
rand('state',0)

Initialize RAND to a different state each time.
rand('state',sum(100*clock))

Save the current state, generate 100 values, reset the state,
and repeat the sequence.
s = rand('state');
u1 = rand(100);
rand('state',s);
u2 = rand(100); % contains exactly the same values as u1


.
.
Learn Matlab by-example!
http://www.matrixlab-examples.com



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.