source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/BlueCCal/MultiCamSelfCal/MartinecPajdla/utils/diff_rand_ints.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 640 bytes
Line 
1%diff_rand_ints Add n random ints in some scope to a given vector.
2%
3%  Add n ints, randomly chosen between from and to inclusive to the list in
4%  ints.  The resulting vector of ints should have all different numbers.
5%
6%    y = diff_rand_ints(ints, n,from,to)
7
8function y = diff_rand_ints(ints, n,from,to)
9
10if (to + 1 - from) < n + size(ints,2)
11  error(sprintf('Not enough room for %d random numbers from %d to %d', n, from, to));
12end
13for i = 1:n
14  x = random_int(from,to-size(ints,2));
15  oldx = from - 1;
16  while oldx < x
17    temp = x;
18    x = x + sum((oldx < ints) & (ints <= x));
19    oldx = temp;
20  end
21  ints = [ints,x];
22end
23y = ints;
Note: See TracBrowser for help on using the repository browser.