Hoe to get size of returned array from C#

1 回表示 (過去 30 日間)
Andreas
Andreas 2015 年 6 月 1 日
回答済み: Martijn 2015 年 9 月 17 日
I am calling a C# dll which is returning some Data. oTG is the returned object.
K>> oTG
oTG =
Calc with properties:
Values: [1x1 System.Double[,,,]]
K>> oTG.Values
ans =
Double[,,,] with properties:
Length: 181222
LongLength: 181222
Rank: 4
SyncRoot: [1x1 System.Double[,,,]]
IsReadOnly: 0
IsFixedSize: 1
IsSynchronized: 0
Ho to get the size of the 4D array oTG.Values?

採用された回答

Martijn
Martijn 2015 年 9 月 17 日
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:
for i=1:numDim
dims(i) = MyNetArray.GetLength(i-1);
end

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange.NET Data Types in MATLAB についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by