How do I pass a javaArray of Doubles to a method that takes double[] arguments from MATLAB?
Show older comments
I am trying to call a Java method that takes a double array argument:
class mySum {
public static double sum(double[] in) {
double accum = 0;
for (int i = 0; i < in.length; i++) {
accum += in[i];
}
return accum;
}
}
When I inspect the class using METHODS:
methods('mySum','-full')
MATLAB reports the following signature:
...
static double sum(double[])
...
I instantiate a java array of Doubles using the JAVAARRAY function in MATLAB and then call the method:
ja = javaArray('java.lang.Double',2)
ja(1) = java.lang.Double(11)
ja(2) = java.lang.Double(12)
b = mySum.sum(ja)
However, I receive the following error:
ERROR: ??? No method 'sum' with matching signature found for class 'mySum'.
Accepted Answer
More Answers (0)
Categories
Find more on Call Java from MATLAB 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!