查看单个帖子
旧 2019-12-10, 20:48   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
帖子 MATLAB Builder JA依赖

我尝试使用MATLAB Builder JA在Java中运行MATLAB代码以获取JAR文件。 test.m工作正常,但不是test2.m取决于test.m 。

我需要项目的依赖项,如何设置?

测试

function [out1] = test(n) out1 = magic(n); 测试2

function [a] = test2() a = test(); 在使用Builder JA构建和打包并在Eclipse中运行之后。

package testJava; import test.*; import com.mathworks.toolbox.javabuilder.*; public class Test { public static void main(String[] args){ testclass a = null; Object[] result = null; try { a = new testclass(); result = a.test2(1,2); System.out.println(result[0]); } catch (MWException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } test2不起作用,但是test正在起作用。如何使test2工作?



回答:

一个问题是test2实际上没有任何输入参数,而test需要一个输入参数。

尝试将test2重写为

function a = test2(in) a = test(in); 另外,您应该仅使用一个输入就test2在代码中调用test2 。



更多&回答...
poster 当前离线   回复时引用此帖