I have an array created in MATLAB that contains a number of cell type objects which contain arrays of doubles.
It’s basically a <1xn cell> array and each cell is an array of doubles.
What I want to do is to somehow export these so that I can then insert the data into Java as a ragged array of arrays of type int. Any thought on how to best do this?
It’s difficult to construct a Java array of primitives in Matlab, because Matlab wants to autobox it back into a Matlab array.
What you can do is create a Java class to help you, using the method signatures to guide Matlab’s autoboxing. A wrapper layer like this may be faster and more convenient than a round trip through a text export.
Then you can call it from Matlab like this.
Afterwards, you’ll need to convert the Object[] array to int[][] within Java, because Matlab will unbox a Java int[][] back to a Matlab array. Keeping it as Object[] within M-code protects it.
You could also build a List or other Collection using similar wrappers. That might mesh better with your other Java code, and Collections don’t unbox in Matlab.