フィルターのクリア

Passing a 2D matrix in to a .NET class method which expects a System.Single[] argument

1 回表示 (過去 30 日間)
KAE
KAE 2018 年 3 月 6 日
コメント済み: KAE 2018 年 3 月 8 日
In Matlab I am calling an existing .NET class which contains methods to perform calculations. I am using one method, let's say DoSomeCalculation, which expects the argument to be in System.Single[] format. It works fine if I pass in a vector of singles from Matlab, but this is slow because I have to call DoSomeCalculation many times. I think it would be faster with one call to DoSomeCalculation if I could pass in a matrix of input vectors, say inputMat = single(rand(10000, 50)) containing 10000 input vectors. There's no error when the argument is inputMat(1,:), but when the argument is inputMat it gives the error,
No method 'DoSomeCalculation' with matching signature found for class 'SomeName.SomeOtherName.YetAnotherName.Calculations'.
Must the argument type be changed to System.Single[,] in order to accept a 2D array, as seems to be the case in the section 'DFS In Matlab' here? If so how can I do this? I apologize that I do not know enough about .NET to make a working example.
  1 件のコメント
KAE
KAE 2018 年 3 月 8 日
It turns out the issue was passing in a 2D matrix when .NET was only expecting a vector. This answer does indicate that it can be faster to "chunk" together input arguments rather than repeatedly calling .NET from a loop.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeGetting Started with Microsoft .NET についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by