Why do I receive the error "...cannot find symbol" or "The method...in the type...is not applicable for the arguments..." when running a program compiled with MATLAB Compiler SDK?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 9 Juil 2010
Modifié(e) : MathWorks Support Team
le 18 Oct 2021
I have created a MATLAB function that accepts two input arguments:
function y = simpleAdd(a,b)
y = a + b;
Using MATLAB Compiler SDK, I create a JAR component, which I try to use in a Java application.
However, when I try to call my compiled MATLAB function from Java I get the following run-time error messages.
From the command prompt, the error is in the form:
ERROR: <Class_Name>:<Line_Number>: cannot find symbol
Specifically:
ERROR: C:\Program Files\Java\jdk1.6.0_18\bin>javac -classpath javabuilder.jar;addarrays
project.jar mainclassaddarray.java
mainclassaddarray.java:50: cannot find symbol
symbol : method addarrays(com.mathworks.toolbox.javabuilder.MWNumericArray,com.
mathworks.toolbox.javabuilder.MWNumericArray)
From the Eclipse IDE, the error is in the form:
ERROR: The method <Method_Signature> in the type <Class_Name> is not applicable for the arguments <Argument_List>
Specifically:
ERROR: "The method addarrays(List, List) in the type AddArray is not applicable for the arguments (MWNumericArray, MWNumericArray)"
Réponse acceptée
MathWorks Support Team
le 18 Oct 2021
Modifié(e) : MathWorks Support Team
le 18 Oct 2021
Check that the method signature you are using to call the method matches the signature of the method generated by MATLAB.
For example, consider the following MATLAB program that adds two arrays:
function outputarray = addarrays(x,y)
outputarray = x+y;
end
When compiled with MATLAB Compiler SDK, three different JAVA methods are produced with the signatures summarized below:
java.lang.Object[] addarrays(int nargout, java.lang.Object... rhs)
Provides the standard interface for calling the addarrays MATLAB function with 2 input arguments.
void addarrays(java.util.List lhs, java.util.List rhs)
Provides the interface for calling the addarrays MATLAB function where the first input, an instance of List, receives the output of the MATLAB function and the second input, also an instance of List, provides the input to the MATLAB function.
void addarrays(java.lang.Object[] lhs, java.lang.Object[] rhs)
Provides the interface for calling the addarrays MATLAB function where the first input, an Object array, receives the output of the MATLAB function and the second input, also an Object array, provides the input to the MATLAB function.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Java Package Integration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!