manipulating list into array
<p>In this program noise is a one-dimensional list 1 x N, where N is the length of the list. N could be as high as 100,000 of time series data. I want to create a number of phseSpaces: 1, 2, ....10, of varying columns from 1, 2,..10, respectively, by manipulating the entries in the noise list and getting entries at specific indexes to populate the new array. As the size of each array varies, I have set the length of the indexes to be equal the length of the noise list less the position of the highest index (which is computed). However, when the program below runs, it throws the following error: "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index". I have read round to find the meaning. I understand it probably the case that the index I refer to in the noise list may not exist. However, I think it is reasonable from my calculation that the highest index (computed) should exist in the noise list, so I am not sure why this is happening. I am new to program and will be grateful for your assistance.  </p>

<pre><code>                   int length = noise.Count;
                   int tdelay1 = 200;
                    int [] embDim = new int [10] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

                    foreach (int m in embDim)
                    {
                        if (m == embDim[0])
                        {
                            float[,] phaseSpace1 = new float[length, m]; 
                            for (int i = 0; i &lt; length-1; i++)
                            {
                                phaseSpace1 [i,0] = noise[i];
                            }
                        }

                        else if (m == embDim[1])
                        {
                            float[,] phaseSpace2 = new float[(length-tdelay1), m];
                            for (int i = 0; i &lt; (length-tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                phaseSpace2 [i,0] = noise[i];
                                phaseSpace2 [i,1] = noise[j];
                            }
                        }

                        else if (m == embDim[2])
                        {
                            float[,] phaseSpace3 = new float[(length-2*tdelay1), m];
                            for (int i = 0; i &lt; (length-2*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                phaseSpace3 [i, 0] = noise[i];
                                phaseSpace3 [i, 1] = noise[j];
                                phaseSpace3 [i, 2] = noise[k];
                            }
                        }

                        else if (m == embDim[3])
                        {
                            float[,] phaseSpace4 = new float[(length-3*tdelay1), m];
                            for (int i = 0; i &lt; (length-3*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                phaseSpace4[i, 0] = noise[i];
                                phaseSpace4[i, 1] = noise[j];
                                phaseSpace4[i, 2] = noise[k];
                                phaseSpace4[i, 3] = noise[l];
                            }
                        }

                        else if (m == embDim[4])
                        {
                            float[,] phaseSpace5 = new float[(length-4*tdelay1), m];
                            for (int i = 0; i &lt; (length-4*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                int n = i + 4 * tdelay1;
                                phaseSpace5[i, 0] = noise[i];
                                phaseSpace5[i, 1] = noise[j];
                                phaseSpace5[i, 2] = noise[k];
                                phaseSpace5[i, 3] = noise[l];
                                phaseSpace5[i, 4] = noise[n];
                            }
                        }

                        else if (m == embDim[5])
                        {
                            float[,] phaseSpace6 = new float[(length-5*tdelay1), m];
                            for (int i = 0; i &lt; (length-5*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                int n = i + 4 * tdelay1;
                                int o = i + 5 * tdelay1;
                                phaseSpace6[i, 0] = noise[i];
                                phaseSpace6[i, 1] = noise[j];
                                phaseSpace6[i, 2] = noise[k];
                                phaseSpace6[i, 3] = noise[l];
                                phaseSpace6[i, 4] = noise[n];
                                phaseSpace6[i, 5] = noise[o];
                            }
                        }

                        else if (m == embDim[6])
                        {
                            float[,] phaseSpace7 = new float[(length-6*tdelay1), m];
                            for (int i = 0; i &lt; (length-6*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                int n = i + 4 * tdelay1;
                                int o = i + 5 * tdelay1;
                                int p = i + 6 * tdelay1;
                                phaseSpace7[i, 0] = noise[i];
                                phaseSpace7[i, 1] = noise[j];
                                phaseSpace7[i, 2] = noise[k];
                                phaseSpace7[i, 3] = noise[l];
                                phaseSpace7[i, 4] = noise[n];
                                phaseSpace7[i, 5] = noise[o];
                                phaseSpace7[i, 6] = noise[p];
                            }
                        }

                        else if (m == embDim[7])
                        {
                            float[,] phaseSpace8 = new float[(length-7*tdelay1), m];
                            for (int i = 0; i &lt; (length-7*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                int n = i + 4 * tdelay1;
                                int o = i + 5 * tdelay1;
                                int p = i + 6 * tdelay1;
                                int q = i + 7 * tdelay1;
                                phaseSpace8[i, 0] = noise[i];
                                phaseSpace8[i, 1] = noise[j];
                                phaseSpace8[i, 2] = noise[k];
                                phaseSpace8[i, 3] = noise[l];
                                phaseSpace8[i, 4] = noise[n];
                                phaseSpace8[i, 5] = noise[o];
                                phaseSpace8[i, 6] = noise[p];
                                phaseSpace8[i, 7] = noise[q];
                            }
                        }

                        else if (m == embDim[8])
                        {
                            float[,] phaseSpace9 = new float[(length-8*tdelay1), m];
                            for (int i = 0; i &lt; (length-8*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                int n = i + 4 * tdelay1;
                                int o = i + 5 * tdelay1;
                                int p = i + 6 * tdelay1;
                                int q = i + 7 * tdelay1;
                                int r = i + 8 * tdelay1;
                                phaseSpace9[i, 0] = noise[i];
                                phaseSpace9[i, 1] = noise[j];
                                phaseSpace9[i, 2] = noise[k];
                                phaseSpace9[i, 3] = noise[l];
                                phaseSpace9[i, 4] = noise[n];
                                phaseSpace9[i, 5] = noise[o];
                                phaseSpace9[i, 6] = noise[p];
                                phaseSpace9[i, 7] = noise[q];
                                phaseSpace9[i, 8] = noise[r];
                            }
                        }

                        else if (m == embDim[9])
                        {
                            float[,] phaseSpace10 = new float[(length-9*tdelay1), m];
                            for (int i = 0; i &lt; (length-9*tdelay1-1); i++)
                            {
                                int j = i + tdelay1;
                                int k = i + 2 * tdelay1;
                                int l = i + 3 * tdelay1;
                                int n = i + 4 * tdelay1;
                                int o = i + 5 * tdelay1;
                                int p = i + 6 * tdelay1;
                                int q = i + 7 * tdelay1;
                                int r = i + 8 * tdelay1;
                                int s = i + 9 * tdelay1;
                                phaseSpace10[i, 0] = noise[i];
                                phaseSpace10[i, 1] = noise[j];
                                phaseSpace10[i, 2] = noise[k];
                                phaseSpace10[i, 3] = noise[l];
                                phaseSpace10[i, 4] = noise[n];
                                phaseSpace10[i, 5] = noise[o];
                                phaseSpace10[i, 6] = noise[p];
                                phaseSpace10[i, 7] = noise[q];
                                phaseSpace10[i, 8] = noise[r];
                                phaseSpace10[i, 9] = noise[s];
                            }                                
                        }         
</code></pre>
