Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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 Kommentar
KAE
KAE am 8 Mär. 2018
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by