% ### EXrandomNum2.m ### 11.15.14 % Generate a rough psuedo-random number distribution using the computer % clock as the initial 'seed', then use the last number for the next clear % --- N= 100; % # of random values to compute modB= 1000; % base value for mod % --- c= clock; temp1= c(6); % use computer clock as the initial 'seed' % loop to generate random values for nn=1:N temp2= mod(modB,temp1); % compute the mod randVal(nn)= ceil(temp2)-temp2; % normalize to [0,1] interval temp1= rem(temp2*10,1); % use (last few digits of) last value to 'reset' seed end figure(1); clf; subplot(211); hist(randVal,20); xlim([0 1]); ylabel('Occurrences'); title(['Pseudo-random number over [0,1] distribution (',num2str(N),' values)']); subplot(212) plot(randVal,'.-'); xlabel('Iterate');