How can I copy one array to another array from specific point?

Dear All,

I want to copy the elements of six different arrays into one single array, size of all the arrays are different and each array contains float types of variables. Can anybody suggest me how can I do it?

Thank you
Regards
Manish

It sounds like you need a series of for loops with appropriate start and end values to pick the data from the source arrays and an index to the target array so that you know where to put the data.

Can you give some examples of the arrays involved.

Dear Mr. HeliBob,

The arrays are meant to store the values recorded from the sensor. The range of values are from -16.00 to 36.00. Right now I dont have the exact case values, but following arrays can considered as the dummy cases.

There are 5 different arrays and lets say I want to dump the information into sixth array which contains all data points (information) from all five arrays.

Example

float Array1[20]={1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.10,1.11,1.12,1.13,1.14,1.15,1.16,1.17,1.18,1.19,1.20};
float Array2[15]={2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,2.10,2.11,2.12,2.13,2.14,2.15};
float Array3[10]={3.1,3.2,3.4,3.5,3.6,3.7,3.8,3.9,3.10};
float Array4[5]={4.1,4.2,4.3,4.4,4.5};
float Array5[3]={5.1,5.2,5.3};

float Array1[20] = {1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.20};
float Array2[15] = {2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.10, 2.11, 2.12, 2.13, 2.14, 2.15};
float Array3[10] = {3.1, 3.2, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 3.10};
float Array4[5] = {4.1, 4.2, 4.3, 4.4, 4.5};
float Array5[3] = {5.1, 5.2, 5.3};

float targetArray[53];


void setup()
{
  Serial.begin(115200);
  int targetIndex = 0;
  for int(x = 0; x < 20; x++)
  {
    targetArray[targetIndex] = Array1[x];
    targetIndex++;
  }

  for int(x = 0; x < 15; x++)
  {
    targetArray[targetIndex] = Array2[x];
    targetIndex++;
  }
}

void loop()
{
}

NOTE: There are safer ways to do this by allowing the program to work out the number of elements in each array but this should give you some ideas of how you could do it.

Why is the data in different arrays in the first place ?

Dear Mr. HeliBob,

The recording of the data is from the different regions hence it is stored in the different arrays. At the end of the program I need to calculate the average, variance etc. hence I need the data to store in one single array.

Thanks for the help, I will try to program it likewise.

Dear Mr. HeliBob,

Thank you for the help. I have tested this code with dummy arrays and it works.

Regards
Manish

The recording of the data is from the different regions hence it is stored in the different arrays.

No this is not true.

I need to calculate the average, variance etc. hence I need the data to store in one single array.

Again this is not true.

Mark

The recording of the data is from the different regions hence it is stored in the different arrays.

Why does the data have to be stored in different arrays ?