Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@math/rand.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % RAND return a random number between r1 and r2 | |
2 % | |
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
4 % | |
5 % DESCRIPTION: RAND return a random number between r1 and r2 | |
6 % | |
7 % CALL: val = rand(r1, r2) | |
8 % | |
9 % INPUTS: r1 - lower limit of the random values | |
10 % r2 - upper limit of the random values | |
11 % | |
12 % OUTPUTS: val - random numbers | |
13 % | |
14 % VERSION: $Id: rand.m,v 1.2 2008/10/24 06:19:23 hewitson Exp $ | |
15 % | |
16 % HISTORY: 26-01-2007 M Hewitson | |
17 % Creation | |
18 % | |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
20 | |
21 function val = rand(r1, r2) | |
22 | |
23 int = r2-r1; | |
24 rand('twister',sum(100*clock)); | |
25 val = r1 + int*rand; | |
26 | |
27 end | |
28 % END | |
29 |