java和matlab混合编程
来源:互联网 发布:java高并发面试题实例 编辑:程序博客网 时间:2024/05/29 14:58
1. 从matlab 2006b版本起,开始提供javabuilder工具箱,以支持向java提供编程接口。
2. 安装matlab编译Runtime: MCR(例如:MATLAB/toolbox/compiler/deploy/win64/MCRInstaller.exe)。
3. 在matlab command window中使用deploytool命令打开deploy窗口。
3.1 新建工程(将被编译为java中的一个Class)
3.2 向工程添加m文件(每个m文件将被编译为一个method)
3.3 build工程,matlab将于指定目录生成相应的jar包(例如MProj.jar)和javedoc文件。
4. 在eclipse中新建java工程,将matlab toolbox中javabuilder.jar和生成的MProj.jar置于java工程的类路径下。
5. OK,可以开始使用javabuiler.jar和MProj.jar提供的接口开始java编程了!javabuilder.jar的API javadoc可在matlab的帮助文档中查询,MProj.jar的API javadoc已在上面2.3中生成。
一个javabuilder工具箱中自带的例子:Compute Magicsquare square and print result
- import com.mathworks.toolbox.javabuilder.*;
- import magicsquare.*;
- public class TestMatlab {
- public static void main(String[] args) {
- MWNumericArray n = null; /* Stores input value */
- Object[] result = null; /* Stores the result */
- Magicsquare theMagic = null; /* Stores magic class instance */
- try {
- /* If no input, exit */
- if (args.length == 0)
- {
- System.out.println("Error: must input a positive integer");
- return;
- }
- /* Convert and print input value */
- n = new MWNumericArray(Double.valueOf(args[0]), MWClassID.DOUBLE);
- System.out.println("Magic square of order " + n.toString());
- /* Create new magic object */
- theMagic = new Magicsquare();
- /* Compute Magicsquare square and print result */
- result = theMagic.makesqr(1, n);
- System.out.println(result[0]);
- } catch (Exception e) {
- System.out.println("Exception: " + e.toString());
- } finally {
- /* Free native resources */
- MWArray.disposeArray(n);
- MWArray.disposeArray(result);
- if (theMagic != null)
- theMagic.dispose();
- }
- }
- }
6. 以上步骤已经可以搞定使用matlab接口编程的大多数情况,但目前为止(我用的是2009a),貌似matlab还不能编译训练模型的函数,如时间序列模型armax(),调用java程序报错:
Undefined function or method 'armax' for input arguments of type 'iddata'.
不知该如何在java中使用armax()这样的函数.
- Java和matlab混合编程
- Java和matlab混合编程
- Java和matlab混合编程
- java和matlab混合编程
- java和matlab混合编程
- Java和matlab混合编程
- 初探java和matlab混合编程
- Matlab和java混合编程开发
- Java和MATLAB混合编程,Java调用MATLAB代码
- Java和MATLAB混合编程,Java调用MATLAB代码
- Matlab与Java混合编程
- java与matlab混合编程
- Java与Matlab混合编程
- VC++和Matlab混合编程
- Matlab和C混合编程
- c和matlab混合编程
- matlab和C++混合编程
- c#和MATLAB混合编程
- LeetCode-543. Diameter of Binary Tree (Java)
- 深入解析php中的foreach问题
- mybatis批量操作中<foreach>标签的使用
- 深入理解 Android NDK 编译(二)
- 值传递,地址传递与引用传递
- java和matlab混合编程
- Linux串口驱动程序(1)-tty架构
- PostgreSQL 数据类型介绍(三)
- 机房重构-七层登录(上)
- Maven工程
- 简单数组查找
- R语言网页抓取入门-rvest包
- Postgres 的全文检索已经足够好了
- c语言