Array with changing value

This time in English.
I create a 2 dimensionnal array, I fill it with 0, when I print it the values are not any more 0 but 1/1000 of the array ligne number

Attach is the sketch
here under the result

Thank’s

Lionel

0 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.00
1 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.00
2 0.002 0.002 0.002 0.002 0.002 0.002 0.002 0.00
3 0.003 0.003 0.003 0.003 0.003 0.003 0.003 0.00
4 0.004 0.004 0.004 0.004 0.004 0.004 0.004 0.00
5 0.005 0.005 0.005 0.005 0.005 0.005 0.005 0.00
6 0.006 0.006 0.006 0.006 0.006 0.006 0.006 0.00
7 0.007 0.007 0.007 0.007 0.007 0.007 0.007 0.00
8 0.008 0.008 0.008 0.008 0.008 0.008 0.008 0.00
9 0.009 0.009 0.009 0.009 0.009 0.009 0.009 0.00
10 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.0010 0.00
11 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.0011 0.00
12 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 0.0012 0.00
13 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.0013 0.00
14 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 0.0014 0.00
15 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.0015 0.00
16 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.0016 0.00
17 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 0.0017 0.00
18 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.0018 0.00
19 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.00
20 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.0020 0.00
21 0.0021 0.0021 0.0021 0.0021 0.0021 0.0021 0.0021 0.00
22 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.0022 0.00
23 0.0023 0.0023 0.0023 0.0023 0.0023 0.0023 0.0023 0.00

sketch_jan10a.ino (509 Bytes)

You are printing i inside your j loop. The floats are all zero, but the i print tacks it on the end and makes it look as if they have been corrupted. Try:

  for (int i = 0; i < 24; i++)
  {
    Serial.print (i);
    Serial.print("     ");
    for (int j = 0; j < 8; j++)
    {
      float x = frequence[i][j];
      Serial.print (x);
      Serial.print("     ");
    }
    Serial.println();
  }
  Serial.println();

I made the change you suggested, but no change at all

Thank you for reply

sketch_jan10a.ino (527 Bytes)

This worked for me:

  for (int i = 0; i < 24; i++)
  {
    Serial.print (i);
    Serial.print(": ");
    for (int j = 0; j < 8; j++)
    {
      Serial.print("\t");
      float x = frequence[i][j];
      Serial.print (x);
    }
    Serial.println();
  }
  Serial.println();

Output:

0: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
1: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
2: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
3: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
4: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
5: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
6: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
7: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
8: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
9: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
10: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
11: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
12: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
13: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
14: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
15: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
16: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
17: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
18: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
19: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
20: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
21: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
22: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00
23: 	0.00	0.00	0.00	0.00	0.00	0.00	0.00	0.00

Thank you
Now it works OK, I do not understand why.
I even check without the intermediate x variable and it still work OK

This is a mystery to me

I cannot see the difference with the code I attached on my first post

sketch_jan10a.ino (523 Bytes)

Original code

float frequence [24][8];

void setup() 
{
  Serial.begin(115200);
  
    for (int i = 0; i < 24; i++)
    {
    for (int j = 0; j < 8; j++)
    {
      frequence[i][j] = 0.00;
    }
  }
  
  for (int i = 0; i < 24; i++)
  {
    for (int j = 0; j < 8; j++)
    {
      Serial.print (i);
      Serial.print("     ");  
      Serial.print (frequence[i][j]);
    }
    Serial.println();
  }
  Serial.println();

}

void loop() {
  // put your main code here, to run repeatedly:

}

New code

float frequence [24][8];

void setup() 
{
  Serial.begin(115200);
  
    for (int i = 0; i < 24; i++)
    {
    for (int j = 0; j < 8; j++)
    {
      frequence[i][j] = 0.00;
    }
  }
  
  for (int i = 0; i < 24; i++)
  {
    Serial.print (i);
    Serial.print(": ");
    for (int j = 0; j < 8; j++)
    {
      Serial.print("\t");
      Serial.print (frequence[i][j]);
    }
    Serial.println();
  }
  Serial.println();
}
void loop() {
  // put your main code here, to run repeatedly:

}

Hint: The values in “frequence” are all zero before setup runs, so no need to set them to zero.