gpt4 book ai didi

java - MATLAB Builder JA 依赖项

转载 作者:行者123 更新时间:2023-11-30 09:52:08 24 4
gpt4 key购买 nike

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

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

测试.m

function [out1] = test(n)
out1 = magic(n);

测试2.m

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,仅使用一个输入。

关于java - MATLAB Builder JA 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4345919/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com