File: Ranint.m

package info (click to toggle)
psychtoolbox-3 3.0.14.20170103%2Bgit6-g605ff5c.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,044 kB
  • ctags: 69,483
  • sloc: ansic: 167,371; cpp: 11,232; objc: 4,708; sh: 1,875; python: 383; php: 344; makefile: 207; java: 113
file content (24 lines) | stat: -rw-r--r-- 611 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function i = Ranint(dim,n)
% i = Ranint([dim],n)
%
% Choose "dim" random integers in the range 1:n.
%
% For historical reasons, the usage is a little weird.  If you omit the dim
% argument, then a single random integer is drawn from the range 1:n. 
% 
% Also see Randi.

% 4/10/94   dhb   Added optional first argument.
% 8/19/94   dhb   Clarified comment.
% 1/20/97   dhb   Delete obsolete rand('uniform').
% 4/12/99   dgp   Changed names of arguments to be consistent with Matlab and Randi.
% 7/24/04   awi   Cosmetic.

if nargin == 1
	n = dim;
	dim = 1;
end

list = rand(dim,1);
i = floor( n .* list ) + 1;