如何从java代码访问matlab函数?

发布于 2024-10-24 15:55:39 字数 374 浏览 5 评论 0原文

我的java程序使用打包为jar文件的matlab代码进行图像处理。问题是当我第一次调用一个函数(由我编写)并调用“mmreader”时,它工作正常。但是,对调用“mmreader”的函数(相同或不同)的任何后续调用都不起作用,并且我收到一条错误消息,指出未找到函数 mmreader。

我在应用程序的另一部分也面临类似的问题,其中对 matlab 函数的调用只是抛出异常,而同一段代码在其他文件中运行良好。

try{
      vplayer.playmov(player_params);
   }
catch(Exception e){
            System.out.println("error playing cluster");
  }

My java program uses matlab code packaged as jar files for image processing. The problem is when I call a function(written by me) with a call to 'mmreader' for the first time, it works fine. However any subsequent call to a function(same or different) calling 'mmreader' doesn't work and I get an error stating function mmreader not found.

I am also facing a similar problem in another part of my application where the call to matlab function simply throws an exception, the same piece of code works fine in other files.

try{
      vplayer.playmov(player_params);
   }
catch(Exception e){
            System.out.println("error playing cluster");
  }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鼻尖触碰 2024-10-31 15:55:39

我会快速浏览一下这个链接 Accessing Matlab from Java
以下是该页面的一些摘录,可能有用。

 mlapp.MLApp mlApp = new mlapp.MLApp(); 

 String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]"); 
 System.out.println("Execute result is " + result); 

在这些引号内,您甚至可以调用 MATLAB 函数,只需确保将输出分配给正确的数据类型即可。

该链接最重要的部分是;

我们假设您已从 http://j-integra.intrinsyc 下载并扩展了 J-Integra® 套件.com/ 并正确安装。

如果没有安装,则无法执行上述语句。

I would take a quick look at this link Accessing Matlab from Java
Here are a couple excerpts from the page that might be useful.

 mlapp.MLApp mlApp = new mlapp.MLApp(); 

 String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]"); 
 System.out.println("Execute result is " + result); 

Inside those quotes, you can even call a MATLAB function, just make sure that you are assigning the output to the right data type.

The most important part of that link is;

We assume you have downloaded and expanded the J-Integra® kit from http://j-integra.intrinsyc.com/ and installed it correctly.

Without that installed, you cannot do the above statement.

柠栀 2024-10-31 15:55:39

除此之外,在 MATLAB 中,您可以使用您的函数创建一个 JAR,并对该 JAR 进行签名,使其仅适用于您的应用程序。也许您需要 MATLAB 运行时才能使该应用程序正常工作,我对此不确定。

Besides that, in MATLAB you can create a JAR with your functions and sign that JAR to only work with your applications. Perhaps you'll need the MATLAB runtime to make that app work I'm not sure about that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文