I have already asked look @ Passing List ,still awaiting for result .if any body know please let me know Thanks.
Passing Matrix List to Java Method ,error:No method 'list_method' with matching signature found for class
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SAMEER ahamed
el 4 de Mzo. de 2014
Editada: SAMEER ahamed
el 6 de Mzo. de 2014
Hi,
On Matlab Part :
matrix =[22,11,33,44,22,44,22,54]; % 1-by-8 matrix
if true
% code
import edu.lipreading.*;
import java.util.Vector;
training = MainMethod;
training.list_method(matrix);
end
On Java Part
if true
% code
public void list_method(List<Integer> points){
System.out.println("Welcome to List Method");
}
end
Note : When I have run my matlab code i got error like No method 'list_method' with matching signature found for class 'edu.lipreading.MainMethod'. // edu.lipreading Package Name ,MainMethod Class name
Respuesta aceptada
Malcolm Lidierth
el 4 de Mzo. de 2014
Try
public void list_method(double[] points){
...
}
Note that MATLAB vectors/matrices contain doubles by default and are passed to Java as a copy.
3 comentarios
SAMEER ahamed
el 5 de Mzo. de 2014
Editada: SAMEER ahamed
el 5 de Mzo. de 2014
SAMEER ahamed
el 5 de Mzo. de 2014
Editada: SAMEER ahamed
el 5 de Mzo. de 2014
Más respuestas (1)
Malcolm Lidierth
el 5 de Mzo. de 2014
Editada: Malcolm Lidierth
el 5 de Mzo. de 2014
OK, if you are stuck with a List java-side, you need to create a list MATLAB-side.
In MATLAB:
- Create a concrete list class
list=java.util.ArrayList()
- Add the elements to it
for k=1:length(matrix)
list.add(int32(matrix(k)));
end
- Check its size:
>> list.size()
ans =
8
Note that the "<Integer>" annotation in your Java code is only relevant at compile time. Casting the MATLAB variable to int32 above ensures that the ArrayList will add a java.lang.Integer to the list at run-time. You could do that explicitly using
list.add(java.lang.Integer.valueOf(matrix(k)));
instead.
Within MATLAB you can access the list elements using "get":
e.g.
list.get(0)
Note that when MATLAB receives the returned Integer, it creates a MATLAB primitive double from it:
>> class(list.get(0))
ans =
double
Java will not - it will use the java.lang.Integer instance in the list.
1 comentario
SAMEER ahamed
el 6 de Mzo. de 2014
Editada: SAMEER ahamed
el 6 de Mzo. de 2014
Ver también
Categorías
Más información sobre Call Java from MATLAB en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!