2024-03-25 05:06:53 | 我爱编程网
我分别百度了那两个问题,解决方案好像是一样的。
把你的matlab的bin的路径添加到系统的path路径中,也可以把你的mcr的bin路径添加到path中,你可以采用命令行的形式:
set Path=%Path%;
或者
set Path=%Path%;
参考网址:
-78FIKN/index.html?product=MJ&solution=1-78FIKN
_thread/296636
原文是:
You are receiving this error because the required "bin" directories of either the MATLAB or MATLAB Compiler Runtime (MCR) installations have not been set up correctly on your Windows machine's PATH environment variable. You can make the necessary runtime libraries visible to MATLAB-compiled components by adding either:
to your system PATH, depending on whether you are developing against a local MATLAB installation, or the MCR. Either replace
新建两个matlab文件
如下所示: //代码是在网上找的,偷了个懒
function out = plotcos(first,step,last)
in = first:step:last;
out = cos(in);
figure('Name','Math Plot - Cos Function','NumberTitle','off');
plot(in, out, 'b-');
axis([first last -1.5 1.5]);
grid on;
title('cos函数曲线');
function out = plotsin(first,step,last)
in = first:step:last;
out = sin(in);
figure('Name','Math Plot - Sin Function','NumberTitle','off');
plot(in, out, 'b-');
axis([first last -1.5 1.5]);
grid on;
title('cos函数曲线');
我爱编程网(https://www.52biancheng.com)小编还为大家带来如何在Java中调用Matlab?的相关内容。
一、matlab版本必须支持java
在command 模式下面运行deploytool,如果支持该命令即可使用
二、matlab中function的书写
%定义一个函数operation(a,b),求a与b的加减乘除运算,并返回结果
%函数定义function 输出变量列表[s,m,...] 函数名(输入变量列表)sum,sub,mul,div中
function [sum,sub,mul,div] = operation(a,b);
sum = a + b;
sub = a - b;
mul = a * b;
div = a / b;
end
PS:上面function后中括号部分与java中调用该operation的返回值有关系,在java中调用的 Object result[] = XXX.operation(4,a,b); 4表示有4个返回值,分别存放在result[0]到result[4]中。
三、使用matlab编译生成jar
在matlab命令窗口下输入 deploytool,就会弹出一个编译窗口,
然后点击,file,选择new-deployment project,
然后选择matlab builder jave。
name的地方填写工程名,
ocation填写该工程的存储位置。
点击ok。
然后,把m文件添加到工程中,先new一个class,这个class的名字就是你将来在java中需要new的class的名字,也就是matlab中operation所在的class名字然后将你的m文件添加到这个class目录下,然后直接build即可。
四、在java中使用matlab的函数
现在eclipse下面new一个新的java工程,然后将第三部build成功后产生的文件夹下面的distrib目录中的XXX.jar 以及你matlab安装目录下/toolbox/javabuilder/jar/javabuilder.jar加入你的java工程extend lib 中去。
然后你可以清晰的看到XXX.jar中包含的函数和类
五、可能碰到的问题
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to find the library libmwmclmcrrt.so.7.13, required by MATLAB Builder JA, on java.library.path.
This library is typically installed along with MATLAB or the MCR, its absence may indicate an issue with that installation or the current path configuration.
The MCR version that this component is trying to use is: 7.13.
Failed to find the library mclmcrrt710.dll,required by MATLAB Builder JA, on java.library.path
原因是2009a要对应安装mclmcrrt7.10。在MATLAB安装目录下查找:\toolbox\compiler\deploy\win32,找到MCRInstaller.exe 安装,重启Eclipse即可。
资料来源:
_stu_zhang/article/details/7605391
2023-12-21 16:29:16
2023-12-24 20:21:11
2024-04-13 17:18:48
2024-04-09 17:44:01
2024-04-04 05:10:44
2024-03-31 15:14:06