input: Write a function to compute the average of the elements of a given 2-dimensional array. Given the array `matrix`, the function should calculate the sum of all elements and then divide by the total number of elements in the array. Finally, return the average as a floating-point number.
  assert averageMatrix([[3,2,6], [8,5,9], [4,7,1]])==5.0
  assert averageMatrix([[1,2], [3,4]])==2.5
  assert averageMatrix([[7,8], [9,10]])==8.5
  assert averageMatrix([[1]])==1.0
  assert averageMatrix([[]])==0.0
output: def averageMatrix(matrix):
      total_sum = 0
      total_count = 0
      for row in matrix:
          total_sum += sum(row)
          total_count += len(row)
      if total_count == 0:
          return 0.0
      return total_sum / total_count