Hoe to get size of returned array from C#
9 views (last 30 days)
Show older comments
I am calling a C# dll which is returning some Data. oTG is the returned object.
Calc with properties:
Values: [1x1 System.Double[,,,]]
Double[,,,] with properties:
SyncRoot: [1x1 System.Double[,,,]]
Ho to get the size of the 4D array oTG.Values?
Martijn on 17 Sep 2015
1. If you have a multidimensional array (like Double[,,,]) and not a Jagged array (like Double), you should be able to simply use:
MATLABMatrix = double(MyNetArray);
To convert the whole matrix to a MATLAB matrix.
2.If you do want to get more information about the dimensions you will need to use the actual .NET methods for this:
So you can first get the number of dimensions:
numDim = MyNetArray.Rank
And then loop through the dimensions calling GetLength:
dims(i) = MyNetArray.GetLength(i-1);
More Answers (0)
Find more on Getting Started with Microsoft .NET 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!