Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:54:53+00:00 2026-05-26T08:54:53+00:00

I have 6 devices sending data at intervals of 10 seconds. Receive this data

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:54:53+00:00Added an answer on May 26, 2026 at 8:54 am

    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:

    var myArray1 = new double[320, 18];
    var myArray2 = new double[8, 18];
    
    int dim2 = myArray1.GetLength(1);
      myArray2[0, 0] =
          myArray1.Cast<double>().Select((val, idx) => new { idx, val }).Where(
            x => x.idx % dim2 == 0 && x.idx / dim2 >= 11 && x.idx / dim2 < 18).Max(x => x.val);
      myArray2[1, 0] =
          myArray1.Cast<double>().Select((val, idx) => new { idx, val }).Where(
            x => x.idx % dim2 == 0 && x.idx / dim2 >= 18 && x.idx / dim2 < 25).Average(x => x.val);
    // ...
    

    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:

    myArray2[0, 0] = double.MinValue;
    myArray2[1, 0] = 0;
    for (int i = 0; i < myArray1.GetLength(0) + 1; i++) {
      if (i >= 11 && i < 18 && myArray1[i, 0] > myArray2[0, 0]) myArray2[0, 0] = myArray1[i, 0];
      if (i >= 18 && i < 25) myArray2[1, 0] += myArray1[i, 0];
      if (i == 25) myArray2[1, 0] /= Math.Abs(25 - 18);
      // ...
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a production system that gathers telemetry data from remote devices. This data
I have a field device which keeps on sending data over to any designated
I have been using https://github.com/Redth/APNS-Sharp to send push notification message to all devices where
I Try to connect a Bluetooth Adapter, which send me some Data after sending
We have cutomers interested in sending their Sql 2008 data to other customers with
We have a mobile Application in a very unsteady WLan Environment. Sending Data to
Mobile devices have started to do link detection fairly well. They now detect links,
I have two devices. One is a HTC Nexus-One running 2.3.6 and another is
I understand most Android devices have a 16mb limit (24mb on Nexus One) on
I want to read the pdf file from raw folder if devices have any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.