The problem is extracting double arrays in a multidimensional object array which itself is kept in a one-dimensional object array that is contained in a variable of object type.
I am trying to use Matlab API in a C# program. The Matlab script returns values in Matlab's matrix form which is then returned to the C# program as an object variable described as above.
An example of the returned data is as follows. The returned variable is called result which contains a one-dimensional object array. The one-dimensional object array contains a 1x4 object array and each of the objects in the 1x4 array contains a double array.
- result {object[1]}
- [0] {object[1, 4]}
+ [0, 0] {double[500, 6]}
+ [0, 1] {double[500, 6]}
+ [0, 2] {double[500, 6]}
+ [0, 3] {double[500, 6]}
How do I extract these double arrays?
Update
To get you a clearer picture of the variable in question, you can run the following code.
object result;
var resultSub1 = new object[1];
double[,] data1 = {{0,0},{0,0}};
double[,] data2 = {{0,0},{0,0}};
double[,] data3 = {{0,0},{0,0}};
double[,] data4 = {{0,0},{0,0}};
object[,] resultSub2 = { { data1, data2, data3, data4 } };
resultSub1[0] = resultSub2;
result = resultSub1;
How do I extract data1, data2, data3 and data4?
resultvalue that looks like it's a one-dimensional, single-element array containing a two-dimensional array, with length of the first rank of just 1, a length of the second rank of 4. But even if one assumes that's what you mean, it's not clear at all what it is you want to convert that to.object result_parent;object[] result_sub1 = new object[1];double[,] data1 = {{0,0},{0,0}};double[,] data2 = {{0,0},{0,0}};double[,] data3 = {{0,0},{0,0}};double[,] data4 = {{0,0},{0,0}};object[,] result_sub2 = { { data1, data2, data3, data4 } };result_sub1[0] = result_sub2;result_parent = result_sub1;How do I call data1, data2, data3 and data4?