I used MatlabConrol to connect Java and MATLAB. I want to send an image path to MATLAB to process it with matching functions and give me back a number of similar images and paths, to show in the Java GUI.
I always get the same error when passing an image path to MATLAB:
Error using eval
Undefined function 'getinput' for input arguments of type 'char'.
Here's my MATLAB function:
function matlab = getinput(input)
results = hgr(input);
And my Java code:
imag = ImageIO.read(fileChoose.getSelectedFile());
ImagePath = fileChoose.getSelectedFile().getAbsolutePath();
public void SendingMatlabControl() throws MatlabConnectionException,
MatlabInvocationException {
// create proxy
MatlabProxy proxy;
// Create a proxy, which we will use to control MATLAB
MatlabProxyFactory factory = new MatlabProxyFactory();
proxy = factory.getProxy();
// Display 'hello world' like before, but this time using feval
try {
// call builtin function
proxy.eval("getinput('imagepath')");
// call user-defined function (must be on the path)
proxy.eval("addpath('E:\\vm')");
proxy.feval("matlab");
proxy.eval("rmpath('E:\\vm)");
} catch (MatlabInvocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Disconnect the proxy from MatLab
proxy.disconnect();
}
getinputis a builtin function, but I couldn't find any mention of it on the MathWorks website. Are you sure this is a builtin function?