function cells = initialize( boxExtreme, N ) rand('state',sum(100*clock)); initRoutine = input('1.Random 2.NDBox 3.Halton 4.UserInput'); if(initRoutine == 1) for j=1:N cells(j,:) = regionSampler( boxExtreme ); end end if(initRoutine == 2) counterArr = zeros( size( boxExtreme, 2 ),1 ); counterArr counterArr=counterArr+2;%skip the number on the border N NN = N+2 tempArray = zeros(size(boxExtreme,2),NN); for i = 1:size(boxExtreme,2) tempArray(i,:) = linspace(boxExtreme(1,i),boxExtreme(2,i),NN); end %this little deal solves the problem of mapping all the linspace results from %tempArray into the points they represent % %The jist is that a counterArray is used as an index to tempArray, and the %numbers overflow from one to the next and they "count" the possible combinations %of tempArray for results. results = zeros( (N).^(size(boxExtreme,2)),size(counterArr,1)); for j = 1:(N).^(size(boxExtreme,2)) for k = 1:size(counterArr,1) if(counterArr(k) > NN-1) counterArr(k) = 2; if(k+1 <= NN-1) counterArr(k+1) = counterArr(k+1)+1; end end interRes(k) = tempArray(k,counterArr(k)); end results(j,:) = interRes; counterArr(1) =counterArr(1)+1; end cells =results; end if (initRoutine == 3) prelimCells = Halton(boxExtreme, N); N2 = 0; for j = 1:N if(testRegion(prelimCells(j,:) ) == 1) N2 = N2 + 1; cells(N2,:) = prelimCells(j,:); end end N=N2; end if (initRoutine == 4) cells =input('input your generators'); end