I have 6 devices sending data at intervals of 10 seconds.
Receive this data and send to 8 arrays.
The first is the index.
The second is the hours.
The next six, are one for each device.
After a predetermined time, the system will stop receiving data.
After stopping, I need to get the maximum, minimum and average of Selections of some 6 arrays and populate another array.
I need a loop for, how do this?
For example.
myArray1 [320,18] and myArray2 [8,18]
How do this:
/*
//myArray2 [0,0] = MAXIMUM (myArray1 from Here [11,0] to Here myArray1 [17,0])
//myArray2 [1,0] = AVERAGE (myArray1 from Here [18,0] to Here myArray1 [24,0])
//myArray2 [2,0] = AVERAGE (myArray1 from Here [25,0] to Here myArray1 [75,0])
//myArray2 [3,0] = AVERAGE (myArray1 from Here [76,0] to Here myArray1 [180,0])
//myArray2 [4,0] = AVERAGE (myArray1 from Here [181,0] to Here myArray1 [320,0])
*/
Regards,
ocaccy
I assume you want to max and average only over specific ranges in the multidimensional array. Using extension methods it’s a bit complicated, but you can do it like this:
The downside is that you’ll be iterating over all elements all the time. So if this is performance critical, I rather suggest doing it the old fashioned way and in one pass:
And a final suggestion: Do not put magic numbers into your code (11, 18, 25, …), but use consts for this. Later on nobody knows anymore what 25 actually means.
EDIT2: I got the extension method solution to work finally.