my $j1x = 0; my $j1y = 0; my $k = 0; my $ctxy = 0; #create the number of bins while($j1x < $kx) { while($j1y < $ky) { $bin[$ctxy] = "bin\t$num"; $binCnt[$ctxy] = 0; $num++; $ctxy++; $j1y++; } $j1y = 0; $j1x++; } #@egvx = x-values, @rgx = range of x-values, @binx = x-bins #@egvy = y-values, @rgy = range of y-values, @biny = y-bins #@upy and @upx = upper-boundaries of yth and xth bins my $j = 0; my $x = 0; my $y = 0; my $c = 0; open(TST,">test.txt"); while($j < $i) #loops through the x-values { while($c < $i)#loops through the y-values { while($y < $ky)#loops through the y-bins { $upy[$y] = $rgy[$y] + 0.1; while($x < $kx)#loops through the x-bins { $upx[$x] = $rgx[$x] + 0.1; #check which bin the x-value falls into if(($egvx[$j] > $rgx[$x])and($egvx[$j] < $upx[$x])) { #print TST "$egvx[$j]\t$rgx[$x]\t$upx[$x]\n"; #record x-center of the bin $binx[$x] = ($rgx[$x] + $upx[$x])/2; #check which bin the y-value falls into if(($egvy[$c] > $rgy[$y])and($egvy[$c] < $upy[$y])) { #record y-center of the bin $biny[$y] = ($rgy[$y] + $upy[$y])/2; $binCnt[$x] += $binCnt[0]; print TST "$binCnt[$x]\n"; #print TST "x: $egvx[$j] $rgx[$x] $upx[$x]\t y: $egvy[$j]\t$rgy[$y]\t$upy[$y]\n"; } } $x++; } $x = 0; #reset x-bins $y++; } $y = 0; #reset y-bins $c++; } $c = 0; #reset y-values until all x-values have been tested $j++; }