%---------------------------------------------------% % binfill4.m % % % % (P335-S11) Baierlein problem 2.1 % % % % Uses random number generator to fill NBIN bins % % with NUM particles. The "simulation" is run for % % 4 different NUM values and a 2x2 layout of bar % % graphs is produced. % % % % Press F5-key to run program. % % 1/10/05 % %---------------------------------------------------% clear; %clear all variables rand('state',sum(100*clock)); %initialize random number generator NUM=[100 100 100 100]; %numbers of particles ... feel free to change these NBIN=10; %number of bins figure(1); %create figure window for i=1:4 % do calulation for each of the 4 NUM values x=zeros(1,NBIN); % initialize x-array with NBIN entries all = 0.0 for j=1:NUM(i) val =rand; % random number in range 0.0