Beginner here with coding problem

I am trying to create a 4x4 array of temperature values. The variable " float tdata[16]" contains the 16 temperature values. Below is my implementation of the array:

void output_array() // generates a matrix of temperature data
{
  float tempArray[4][4] = { {tdata[0],tdata[1],tdata[2],tdata[3]},
  {tdata[4],tdata[5],tdata[6],tdata[7]},
  {tdata[8],tdata[9],tdata[10],tdata[11]},
  {tdata[12],tdata[13],tdata[14],tdata[15]} };
  
  Serial.print(tempArray); // Prints matrix of temperature data
  
}

This returns the following error message:

thermal_array_d6t.ino: In function 'void output_array()':
thermal_array_d6t:81: error: call of overloaded 'print(float [4][4])' is ambiguous

I have tried researching online to find the solution but either I haven't understood the problem well enough or my understanding of programming is insufficient. Any help is appreciated.

There is no single print that will print a matrix of floats - that's what the error message is telling you.
Use a pair of nested for loops.

As mentioned before by AWOL, a pair of nested loops will solve your problem.
Here is an example: (You may need to change how the for-loop goes through the array to print the values in the order you want.)

// loops through the rows of the tempArray ( 0 to 3)
for (int row = 0; row < 4;  row++) { 
    // loops through the column of the tempArray ( 0 to 3)
    for (int column = 0; column < 4;  column++) { 
        // Print the value to the serial port
        Serial.print(tempArray[row ][column ] );
    }
}

Thank you guys for your responses. I did some research on nested for loops. I'm still having trouble understanding how to get the data into a 4x4 matrix. I used the following code:

void output_array() // generates a matrix of temperature data
{
  float tempArray[4][4] = { {tdata[0],tdata[1],tdata[2],tdata[3]},
  {tdata[4],tdata[5],tdata[6],tdata[7]},
  {tdata[8],tdata[9],tdata[10],tdata[11]},
  {tdata[12],tdata[13],tdata[14],tdata[15]} };
  
  for (int i=0; i<4; i++)
  {
    for (int j=0;j<4; j++)
    {
      Serial.print(tempArray[i][j]);
    }
  }
}

The serial monitor returned the temperature data in a 1x16 array. How could I arrange the rows and columns in the for loop to give me the desired 4x4 matrix form?

Radius:
The serial monitor returned the temperature data in a 1x16 array. How could I arrange the rows and columns in the for loop to give me the desired 4x4 matrix form?

How about something like:

  for (int i=0; i<4; i++)
  {
    for (int j=0;j<4; j++)
    {
      Serial.print(tempArray[i][j]);
      Serial.print(" ");
    }
    Serial.println();
  }

Not formatted but I think you'll get the idea.

Regards,

Brad
KF7FER

I used several for loops to get the 4x4 form to appear in the serial monitor. Below is my implementation:

void output_array() // generates a matrix of temperature data
{
  float tempArray[4][4] = { {tdata[0],tdata[1],tdata[2],tdata[3]},
  {tdata[4],tdata[5],tdata[6],tdata[7]},
  {tdata[8],tdata[9],tdata[10],tdata[11]},
  {tdata[12],tdata[13],tdata[14],tdata[15]} };
  
  for (int i=0; i<1; i++)
  {
    for (int j=0;j<4; j++)
    {
      Serial.print(tempArray[i][j]);
      Serial.print(" ");
    }
  }
  Serial.print("\n");
   for (int i=1; i<2; i++)
  {
    for (int j=0;j<4; j++)
    {
      Serial.print(tempArray[i][j]);
      Serial.print(" ");
    }
  }
  Serial.print("\n");
  for (int i=2; i<3; i++)
  {
    for (int j=0;j<4; j++)
    {
      Serial.print(tempArray[i][j]);
      Serial.print(" ");
    }
  }
  Serial.print("\n");
  for (int i=3; i<4; i++)
  {
    for (int j=0;j<4; j++)
    {
      Serial.print(tempArray[i][j]);
      Serial.print(" ");
    }
  }
}

Thank you AWOL, Guilleduino and Brad for your help. I now have a better understanding of how nested for loops work.

I now have a better understanding of how nested for loops work.

No you don't. All 4 of your outer for loops iterates exactly once. They are, therefore, useless, and you might as well save processing time by getting rid of them.

Paul's right...you don't know what you're doing. The code you posted doesn't even compile.

Study this until you completely understand what every statement does:

void setup()
{
  Serial.begin(115200);
  output_array();
}

void loop()
{
}

void output_array() // generates a matrix of temperature data
{
  int i, j, index;
  float tempArray[4][4];
  
  index = 0;
  for (i = 0; i < 4; i++) {
    for (j = 0;j < 4; j++) {
      tempArray[i][j] = (float) index++;  // Fill the array
    }
  }
  for (i = 0; i < 4; i++) {
    for (j = 0;j < 4; j++) {
      Serial.print(tempArray[i][j]);      // Now show it
      Serial.print(" ");
    }
    Serial.print("\n"); 
  }
}