function UEGPTS = unevenGroups2d(randtype); % UEGroups(randtype) - Produces a random number of groups, with random numbers of % group members, 100 points total. % % User is asked to choose a type of random numbers (randtype): uniform ('u'), or % normally distributed ('n'), to use within the groups. % Calls randgrpsize, which generates the number/composition of the groups, % in a matrix called GS. randgrpsize % Identifies the no. of groups, (ng), and total number, (N), for later use. ng = size(GS,2); N = 100; % Next, the theoretical radius of each groups is calculated, and placed in a % matrix R. R = []; % Initialize R. for g = 1:size(GS,2) % Loop over all groups. n = GS(1,g); % Pull out the group size from GS. r = sqrt(3.125 * n); % Calculate the radius based on the size. R = [R r]; % Place that radius in the matrix, and start again. end % Now, the center points for the groups are generated, based on ng and and the % radii in R, which determine the min distances between group centers. C = uegrpcntrs(ng,R); CPTSN = []; % Initialize the CPTSN matrix. % Now, each group size value is pulled out individually, and points % generated by the circlefish function. The CPTS matrix is built from the % points thus generated. for f = 1:ng gs = GS(1,f); % Identifies the individual group % size (f,a column of matrix GS). if randtype == 'u' CPTS = circlefish(gs); % For uniform randoms, run % circlefish. elseif randtype == 'n' CPTS = DRandompts(gs); % For norm. dist. randoms, use % DRandompts. end V = C(f,:); % Takes the group center location % from matrix C, so that the group % position may be adjusted below. CPTS(:,2) = CPTS(:,2) + V(1,1); % Adjust the x-coordinates. CPTS(:,3) = CPTS(:,3) + V(1,2); % Adjust the y-coordinates. CPTS(:,4) = f; % Attach a group number to each point, % so that groups may be identified. CPTSN = [CPTSN; CPTS]; % Build the matrix. end % Close the loop. CPTSN(:,1) = [1:N]'; UEGPTS = CPTSN; % Final product is labelled UEGPTS.