# How to observe a 2-D variable array

• ### Question

• Hi, can some one tell me how to observe a 2-D variable array. I tried the following codes. All can pass language compiling, yet all are problematic in execution.

```Range rangeCol = new Range(5);
Range rangeRow = new Range(2);
VariableArray<VariableArray<double>, double[][]> myV2D;
myV2D = Variable.Array(Variable.Array<double>(rangeCol), rangeRow);
double[][] myData = {};  // some data are assigned.
for (int i=0; i<rangeRow.SizeAsInt; i++)
for (int j=0; j<rangeCol.SizeAsInt; j++)
myV2D[i][j].ObservedValue = myData[i][j];
```

The above version has an error "{"vdouble[][]1[vint124][vint125] is an array element.  To set the value of the array, use vdouble[][]1[vint124].ObservedValue"}"

```Range rangeCol = new Range(5);
Range rangeRow = new Range(2);
VariableArray<VariableArray<double>, double[][]> myV2D;
myV2D = Variable.Array(Variable.Array<double>(rangeCol), rangeRow);
double[][] myData = {};  // some data are assigned.
for (int i=0; i<rangeRow.SizeAsInt; i++)
for (int j=0; j<rangeCol.SizeAsInt; j++)
myV2D[i].ObservedValue[j] = myData[i][j];```

The above version has the error "{"vdouble[][]1[vint122] is an array element.  To get the ObservedValue of the array, use vdouble[][]1.ObservedValue"}"

```Range rangeCol = new Range(5);
Range rangeRow = new Range(2);
VariableArray<VariableArray<double>, double[][]> myV2D;
myV2D = Variable.Array(Variable.Array<double>(rangeCol), rangeRow);
double[][] myData = {};  // some data are assigned.
for (int i=0; i<rangeRow.SizeAsInt; i++)
for (int j=0; j<rangeCol.SizeAsInt; j++)
myV2D.ObservedValue[i][j] = myData[i][j];```

The above version has the error "{"No ObservedValue has been set on vdouble[][]1"}".

Can some one tell me what's the correct way to use iteration (instead of range) to assign observed value to a 2-D variable array?

Thanks!

Tuesday, June 9, 2015 5:11 PM

`myV2D = myData;`