...

View Full Version : Addition Columns for Matrix



naifz33
08-07-2009, 04:13 AM
I know how to Sum, Average, Max and Min the rows... but how do i do the same for the columns

####### FOR THE ROWS ########
print "Average\tSum\tMax\tMin\n";
while (<FILE>){
chomp;
my @array = split(/\t/);
my $length = @array;
my $count = 1;
my @max = sort{$a <=> $b}@array;
my @min = reverse(@max);
my $sumrow;
while ($count <= $length){
$sumrow += $array[$count-1];
$count++;
}
my $aver = sprintf("%.2f", $sumrow/$length);
print $aver."\t".$sumrow."\t".$max[$length-1]."\t".$min[$length-1]."\n";
}

THANKS!!

also in:
http://forums.devshed.com/perl-programming-6/add-columns-for-matrix-630313.html#post2308990



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum