Search code examples
javamatlabmatlab-deploymentjavabuilders

Extracting CellArray values into java datatype


I'm doing matlab java interfacing using javabuilder. In my matlab code, the function returns a cellarray which is to be casted to java datatype. The value cellarray is retrieved into MWArray. But

I'm not able to cast individual cell data into java datatype.

The cellArray contains string data in each cell. say the cellarray is casted to MWArray 'x' variable. Can any one explain me how to do further casting?


Solution

  • I've got the answer to this question... the value returned should be casted to MWCellArray and later getCell function should be used to get the cell value which will be MWArray object.

    This MWArray is the value returned..

    The code will be::

    Object[] o = <matlab function called>
    MWCellArray x = (MWCellArray)o[0];
    
    MWArray arr = x.getCell(new int[]{1,1});
    

    in my case arr was represeting a String. So, arr.toString() gives the required result .. :)