Is there a size limitation to converting 3D array from C# to MWNumericArray?
Show older comments
I have a c# application that needs to send some data to Matlab. The data is a 3D array of shorts.
My c# Conversion method looks like so:
public static MWArray ShortArrayToMWArray(short[,,] intArray, int v, int v1, int v2)
{
try
{
//MWArray MW = new MWNumericArray(intArray);
//return MW;
MWNumericArray matrix = null;
matrix = new MWNumericArray(MWArrayComplexity.Real, MWNumericType.Int8, v, v1, v2);
matrix = intArray;
return matrix;
}
catch (Exception ex)
{
Console.WriteLine(ex);
return new MWNumericArray();
}
}
My array is: {short[532, 512, 512]}. When I send in the whole thing, I get a very bizarre error message:

It's only when I started to play with the sizes that I started to doubt and ask this question. If I send in 1/4 of the array, it does the conversion (1/2 is still the same error):
// Copy 1/4 of the array into a tmp array
Array tmpArray = Array.CreateInstance(typeof(short), originalArray.GetLength(0)/4, originalArray.GetLength(1)/4, originalArray.GetLength(2)/4);
System.Array.Copy(voxelArray, tmpArray, originalArray.GetLength(0)/4 * originalArray.GetLength(1)/4 * originalArray.GetLength(2)/4);
MWArray mwVol = MatlabUtils.ShortArrayToMWArray((short[,,])tmpArray, originalArray.GetLength(0) / 4, originalArray.GetLength(1) / 4, originalArray.GetLength(2) / 4);
I'm guessing I'm doing the conversion wrong, but not sure.
Thanks
Answers (0)
Categories
Find more on Deploy to Java Applications Using MWArray Data API in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!