Is there a size limitation to converting 3D array from C# to MWNumericArray?
이전 댓글 표시
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
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Deploy to Java Applications Using MWArray Data API에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!