I have written a code to manipulate the contents of a time series data and output into a newly created matrix. This is to enable me construct the phase space for the time series data.
The list is one-dimensional of length=N called “noise”.
I want to create a MxN matrix where m = N -5*tdelay1 and n = 6. When the code complies it displays an error:
Index was outside the bounds of the array.
The code is below:
float[,] phaseSpace6 = new float[(length-5*tdelay1-1), m];
for (int i = 0; i < (length-5* tdelay1-1); i++)
{
int col1 = i + tdelay1;
int col2 = i + 2 * tdelay1;
int col3 = i + 3 * tdelay1;
int col4 = i + 4 * tdelay1;
int col5 = i + 5 * tdelay1;
phaseSpace6[i, 1] = noise[i];
phaseSpace6[i, 2] = noise[col1];
phaseSpace6[i, 3] = noise[col2];
phaseSpace6[i, 4] = noise[col3];
phaseSpace6[i, 5] = noise[col4];
phaseSpace6[i, 6] = noise[col5];
}
I am not sure why this is happening, as someone new to programming. I will be grateful if some experienced person could help me out.
If the N dimension of your MxN array is 6 as stated then
[i, 6]is going to be out of bounds. Numbering for arrays starts at 0 not 1.