Is it possible to invoke a method in a Java class that accepts variable number of input arguments in MATLAB 7.7(R2008b)?
이전 댓글 표시
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'.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!