The help for this file says that a 0 as the third input removes duplicates and 1 keeps them (lines 23-25). This is backward. It is listed correctly in the example however. Otherwise, its a useful function.
Comment only
10 Nov 2009
Random Integer Generator
This program quickly outputs n random integers in the specified range from a to b.
See also http://www.mathworks.com/matlabcentral/fileexchange/16467 which I am the author of. While it only operates on one matrix, it is generalized to operate over any dimension.
Comment only
01 Feb 2008
Random Integer Generator
This program quickly outputs n random integers in the specified range from a to b.
John D'Errico
Perhaps one of the changes made fixed the bug I found. This now works properly:
rand_int(1,3,2)
ans =
1
3
5
31 Jan 2008
Random Integer Generator
This program quickly outputs n random integers in the specified range from a to b.
John D'Errico
Better now. But further testing found a new bug. Sampling 2 integers from a range that is 4 integers long or longer works fine.
rand_int(1,4,2)
ans =
4
2
But, if I want exactly 2 random integers from the set [1 2 3], I only get 1 integer.
rand_int(1,3,2)
ans =
3
The other improvements bring this much closer to a 5. I'd have rated it a 5 until I found this problem. Since this bug (it should be a trivial fix) would push me down to a 4 rating, I won't propose a new rating until I check back for the repaired version.
Comment only