Is it possible to invoke a method in a Java class that accepts variable number of input arguments in MATLAB 7.7(R2008b)?
Afficher commentaires plus anciens
Here is the sample Java code that accepts variable number of arguments:
public class TestVarArgs {
// calculate average of numbers of type 'double'
public static double average( double... numbers )
{
double total = 0.0; // initialize total
for ( double d : numbers )
total += d;
return total / numbers.length;
}
// calculate average of numbers of type 'Double'
public static Double averageD( Double... numbers )
{
Double total = 0.0;
for ( Double d : numbers )
total += d;
return total / numbers.length;
}
}
When I try to invoke any of the above methods in MATLAB as follows:
a = TestVarArgs
a.average(7,6)
a.averageD(java.lang.Double(23), java.lang.Double(34))
I get the following errors respectively:
??? No method 'average' with matching signature found for
class 'VarargsTest'.
??? No method 'averageD' with matching signature found for class
'VarargsTest'.
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!