Uniformly distributed random numbers which fulfill the condition r_min < r_rand < r_max of an n-sphere
nsphrand([M N D]) or nsphrand(M,N,D) generates an M-by-N matrix of random numbers with the dimensionality D where D can for instance be one of the following:
D=1 => 0-sphere (line)
D=2 => 1-sphere (circle)
D=3 => 2-sphere (sphere)
etc
The components of the last dimension D is the vector of the sphere, which length can thus be interpreted as the radius.
r = nsphrand(...,'Rmin',rmin,'Rmax',rmax) sets the min and max radius for the generated random numbers (default 0 and 1).
Example:
r = nsphrand(10000, 1, 2, 'Rmin', 1, 'Rmax', 2)
plot(r(:,1),r(:,2),'.')