% ### EXrandomNum1.m ### 11.15.14 % Generate a rough psuedo-random number distribution using the computer % clock as the 'seed' in a mod framework (i.e., modulus after division). % --> Note that while values can be optimized somewhat, this is not a % very good way top do this! clear % --- N= 100; % # of random values to compute modB= 1000; % base value for mod % --- % loop to generate random values for nn=1:N c= clock; temp1= c(6); % use computer clock as 'seed' temp2= mod(modB,temp1); % compute the mod randVal(nn)= ceil(temp2)-temp2; % normalize to [0,1] interval pause(0.01); 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');