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

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Getting 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