如何从java代码访问matlab函数?
我的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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会快速浏览一下这个链接 Accessing Matlab from Java
以下是该页面的一些摘录,可能有用。
在这些引号内,您甚至可以调用 MATLAB 函数,只需确保将输出分配给正确的数据类型即可。
该链接最重要的部分是;
如果没有安装,则无法执行上述语句。
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.
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;
Without that installed, you cannot do the above statement.
除此之外,在 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.