Tuesday, 15 May 2012

java - Getting a multidimensional array with the 'returningFeval' method in matlabcontol -



java - Getting a multidimensional array with the 'returningFeval' method in matlabcontol -

i'm using matlabcontrol command matlab remotely java, there way multidimensional numeric array out of object array returned java returningfeval method? returningfeval method returns object array , object[0] matlab 2-d array of doubles.

for example:

matlabproxyfactory mill = new matlabproxyfactory(); matlabproxy proxy = factory.getproxy(); object[] mydata = proxy.returningfeval("myfunction", 2, "arg"); double[][] a2darray = mydata[0];

this returns:

classcastexception: "[d cannot cast [[d."

i know can array using matlabtypeconverter class , .getnumericarray method, wouldn't doing returned 'mydata[0]'.

any ideas?

arrays.copyof() method can used convert object arrays arrays of other types without classcastexceptions if compatible.

double[][] integerarray = arrays.copyof(a, a.length, double[][].class);

http://docs.oracle.com/javase/7/docs/api/java/util/arrays.html#copyof(u[],%20int,%20java.lang.class)

java arrays matlab multidimensional-array

No comments:

Post a Comment