I'm stuck trying 2d arrays.

Thank you.

I'm still in trouble sadly

The error suggests that numPorts is not declared somewhere but haven't I set is as a global in line 2?

//-----------------
//set up the global variables
const int numReadings = 10;
const int numPorts = 2;
long numberofReadings=numReadings;
int readings[numReadings][numPorts];      // the readings from the analog input ports
int readIndex[numPorts];// the index of the current reading


float total[numPorts];                  // the running totals for each port
float average[numPorts];                // the average for each port


void setup() {
  // initialize serial:
  Serial.begin(9600);
  analogReference(EXTERNAL);
  InitArray(readings,numReadings,numPorts); //call function to pre-fill the arrays 
}

void loop() {
  average= GetNewAverage(readings);
  // send it to the computer as ASCII digits
  Serial.print(average);
  Serial.print("  ");
  delay(1000);        // delay in between reads for stability
  Serial.println("  ");
}
void InitArray(int readings[][numPorts]){
  // initialize all the readings to an initial read value from each port
  for (int j=0; j< numPorts; j++){
    int initReading=analogRead(j);
    for (int i = 0; i < numReadings; i++) readings[i][j] = initReading;
    total[j]=numberofReadings*initReading;
    average[j]=initReading;
  }
}
float GetNewAverage(int readings[][numPorts]){
  for (int j=0;j<numPorts; j++){
    // subtract the last reading:
    total = total - readings[readIndex][j];
    // read from the sensor:
    readings[readIndex][j] = analogRead(j);
    // add the reading to the total:
    total = total + readings[readIndex][j];
    // advance to the next position in the array:
    readIndex = readIndex + 1;
    // if we're at the end of the array...
    if (readIndex >= numReadings) {
      // ...wrap around to the beginning:
      readIndex = 0;
    }
  }
}

errors:

Func7_2_dimensional_array:7: error: 'numPorts' was not declared in this scope
Func7_2_dimensional_array:8: error: 'numPorts' was not declared in this scope
Func7_2_dimensional_array.ino: In function 'void setup()':
Func7_2_dimensional_array:7: error: too many arguments to function 'void InitArray()'
Func7_2_dimensional_array:19: error: at this point in file
Func7_2_dimensional_array.ino: In function 'void loop()':
Func7_2_dimensional_array:8: error: too many arguments to function 'float GetNewAverage()'
Func7_2_dimensional_array:23: error: at this point in file
Func7_2_dimensional_array:23: error: incompatible types in assignment of 'float' to 'float [2]'
Func7_2_dimensional_array:25: error: call of overloaded 'print(float [2])' is ambiguous
C:\Documents and Settings\RCM\Desktop\Calorimeter development environment\arduino-1.0.5\hardware\arduino\cores\arduino/Print.h:58: note: candidates are: size_t Print::print(char)
C:\Documents and Settings\RCM\Desktop\Calorimeter development environment\arduino-1.0.5\hardware\arduino\cores\arduino/Print.h:59: note: size_t Print::print(unsigned char, int)
C:\Documents and Settings\RCM\Desktop\Calorimeter development environment\arduino-1.0.5\hardware\arduino\cores\arduino/Print.h:60: note: size_t Print::print(int, int)
C:\Documents and Settings\RCM\Desktop\Calorimeter development environment\arduino-1.0.5\hardware\arduino\cores\arduino/Print.h:61: note: size_t Print::print(unsigned int, int)
C:\Documents and Settings\RCM\Desktop\Calorimeter development environment\arduino-1.0.5\hardware\arduino\cores\arduino/Print.h:62: note: size_t Print::print(long int, int)
C:\Documents and Settings\RCM\Desktop\Calorimeter development environment\arduino-1.0.5\hardware\arduino\cores\arduino/Print.h:63: note: size_t Print::print(long unsigned int, int)
Func7_2_dimensional_array.ino: In function 'float GetNewAverage(int ()[2])':
Func7_2_dimensional_array:42: error: invalid types 'int (
)[2][int [2]]' for array subscript
Func7_2_dimensional_array:44: error: invalid types 'int ()[2][int [2]]' for array subscript
Func7_2_dimensional_array:46: error: invalid types 'int (
)[2][int [2]]' for array subscript
Func7_2_dimensional_array:48: error: incompatible types in assignment of 'int*' to 'int [2]'
Func7_2_dimensional_array:50: error: ISO C++ forbids comparison between pointer and integer
Func7_2_dimensional_array:52: error: incompatible types in assignment of 'int' to 'int [2]'