How do I pass a javaArray of Doubles to a method that takes double[] arguments from MATLAB?
Afficher commentaires plus anciens
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'.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Call Java from MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!