function [mcrowding] = meancrowd3d(ARRAY); % MEANCROWD(ARRAY) --- Determines Lloyd's Mean Crowding index for an ARRAY of % points. The ARRAY should be in standard format. % Calculates the Lloyd's Mean Crowding index. % I adapted ian's algorithm to work in 3-d. I don't know what Lloyd's MCI is!?! % Based on meancrowd by Ian McFarland, University of Washington % Modified to handle 3-D case by Jim Work, University of South Carolina, August 13, 2003 % Initialize matrix for 'no. of others' values, per individual. OTHERS = []; % Now, the big loop. For each point i, the distance to each other point % will be calculated, and stored as DISTi. Then, the number of points % less than 6 BL away is found; 6 BL is the radius of our "ambit", since % this was how the field size was calculated. for i = 1:size(ARRAY,1) % For each individual... DISTi = []; for j = 1:size(ARRAY,1) % ...to each other... % ...calc. the distance. dist = dist3d(ARRAY(i,2),ARRAY(i,3),ARRAY(i,4),ARRAY(j,2),ARRAY(j,3),ARRAY(j,4)); DISTi = [DISTi dist]; % DISTi matrix is built. end N = find(DISTi < 6.0); % Determine the number of % dist. under 6 for this point. n = size(N,2) - 1; % Determine no. of "others"; 1 % is subtracted, since there % will be a zero val in DISTi % for the dist. from i to % itself. OTHERS = [OTHERS n]; % Build matrix of "other" vals. end % End the big loop, go on to next point. % Now, find the mean no. of others per individ., the Mean Crowding. mcrowding = sum(OTHERS) / size(ARRAY,1);