www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/RandomNumbersWithinSpecifiedIntervalExample.m

    %% Random Numbers Within Specified Interval  

%% 
% Generate a 10-by-1 column vector of uniformly distributed numbers in the
% interval (-5,5). 
r = -5 + (5+5)*rand(10,1) 

%%
% In general, you can generate |N| random numbers in the interval (a,b)
% with the formula |r = a + (b-a).*rand(N,1)|.