开发者

parse array contains 6 bits of data, i want to parse each part and put it into its own array so i can find averages etc

开发者 https://www.devze.com 2023-03-05 18:45 出处:网络
Each part of my array has 6 bits of data shown here 8300-1050 8300-1050 8500-1050 8700-1050 8900-1050 i need to parse each one into a new array so i can then go on to find averages and more.

Each part of my array has 6 bits of data shown here

   83   0   0   -1  0   50
   83   0   0   -1  0   50
   85   0   0   -1  0   50
   87   0   0   -1  0   50
   89   0   0   -1  0   50

i need to parse each one into a new array so i can then go on to find averages and more. the first colum is heartrate the second is speed and is to the power of 10 so will need to be in some sort of decimal i was thinking floating point. cheers for any help

this is what ive got so far

        int[] hrDataList = new int[5];
   开发者_Go百科     string[] seperator = { "\t" };
        for (int i = 0; i < hrDataList.Length; i++)
        {
            string[] temp = hrDataList[i].ToString().Split(seperator, StringSplitOptions.None);

            heartrate[i] = int.Parse(temp[0]);
            speed[i] = int.Parse(temp[1]);
            cad[i] = int.Parse(temp[2]);
            alt[i] = int.Parse(temp[3]);
            pwr[i] = int.Parse(temp[4]);
            pwrbal[i] = int.Parse(temp[5]);

        }


Try something like this:

            int[] thearray = new int[5];
        int[][] thenewarray = new int[5][];
        string[] seperator = { "\t" };
        for (int i = 0; i < thearray.Length; i++)
        {
            string[] temp = thearray[i].ToString().Split(seperator, StringSplitOptions.None);
            int[] toadd = new int[temp.Length];
            thenewarray[i] = new int[temp.Length];
            for (int j = 0; j < temp.Length; j++)
            {
                thenewarray[i][j] = int.Parse(temp[j]);
            }
        }

Tested and works.

0

精彩评论

暂无评论...
验证码 换一张
取 消