在MatlabControl中使用eval时出错 [英] Error using eval in matlabcontrol

查看:154
本文介绍了在MatlabControl中使用eval时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 MatlabConrol 来连接Java和MATLAB.我想向MATLAB发送一个图像路径,以使用匹配的函数对其进行处理,并给我一些类似的图像和路径,以显示在Java GUI中.

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.

将图像路径传递给MATLAB时,我总是会遇到相同的错误:

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'.

这是我的MATLAB函数:

Here's my MATLAB function:

function matlab = getinput(input)
results = hgr(input);

还有我的Java代码:

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();
  }

推荐答案

让我举一个调用函数,将其传递给输入并检索输出的示例.有两种方法:

Let me give an example of calling a function, passing it input, and retrieving the output. There are two ways, either:

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆