当前位置:首页 » 编程软件 » matlabjava混合编程

matlabjava混合编程

发布时间: 2023-02-28 22:45:36

㈠ matlab与java混合编程有什么作用

Java和matlab混合编程

如果用Matlab和java混合编程开发Windows的应用程序则可以实现优势互补,缩短开发时间,降低程序设计的复杂度。同时程序可以脱离Matlab环境独立运行,在工程计算和教学实践中都具有实际意义。
1.使用java调用Maltab函数的基本方法是:通过Java Builder实现Java调用Matlab。在Java环境中直接调用Matlab所生成的Jar包。

下面以在Java中产生任意维数的魔方矩阵,计算任意矩阵的特征向量和特征值,对两组数据进
行拟合并绘制拟合曲线三个实例来说明通过Java
Builder实现Java调用Matlab的过程。传统的纯Java编程实现上述实例非常复杂,甚至很难完成。这一问题在Matlab中只需要调用几个
函数即可完成。

1.1、将Matlab函数包装成Java类

首先在Matlab中编写三个M文件:

Eig.m

function [v,d]=Eig(input)

format long

[v,d]=eig(input);

End

Magic.m

function f =Magic( input )

f=magic(input);

end

Plot.m

function Plot(x,y )

p=polyfit(x,y,3);

t=min(x):max(x)/100:max(x);

s=polyval(p,t);

plot(x,y,'*',t,s);

title('数据拟合结果');

xlabel('x');

ylabel('y');

end

其次,在Matlab中新建一个Deployment
Project,名称为MyProject.prj,类型为Java
package。在Project中新建三个Class,分别为GetEig,GetMagic,PolyFit。将
Eig.m,Magic.m,plot.m分别添加到上述Class中。之后点击Builder the project,等待编译成功即可。

1.2、在Java中调用Matlab函数

新建一个Java类JavaMatlab,并引入相关的包。

import com.mathworks.toolbox.javabuilder.*;//引入Matlab相关包

import MyProject.*;//引入建立的包及类

调用时Java与Matlab之间的参数传递需要通过MWNumericArray完成。具体的调用代码如下:

package org.genius.ExpandJava;

import MyProject.*;

import com.mathworks.toolbox.javabuilder.*;

public class JavaMatlab {

public static void main(String[] args) {

MWNumericArray a = null; // 用于保存矩阵

MWNumericArray ax = null; // 用于保存矩阵

MWNumericArray ay = null; // 用于保存矩阵

Object[] result = null; // 用于保存计算结果

GetEig getEig = null;

GetMagic getMagic=null;

PolyFit polyFit=null;

int r = 4; // 魔方矩阵维数

int array[][]={{50,-20,0},{-20,80,60},{0,60,-70}};

double x[]={0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1};

double y[]={-0.447,1.978,3.28,6.16,7.08,7.34,7.66,9.56,9.48,9.3,11.2};

try {

//产生魔方矩阵并打印

a = new MWNumericArray(r, MWClassID.DOUBLE);

getMagic = new GetMagic();

result = getMagic.Magic(1,a);

System.out.println("产生的四维魔方矩阵:");

System.out.println(result[0]);

MWArray.disposeArray(result);

//计算所给矩阵的特征向量和特征值并打印结果

a = new MWNumericArray(array, MWClassID.DOUBLE);

getEig = new GetEig();

result = getEig.Eig(2, a);

System.out.println("原始矩阵:");

System.out.println(a.toString());

System.out.println("得到的特征向量:");

System.out.println(result[0]);

System.out.println("得到的特征值:");

System.out.println(result[1]);

MWArray.disposeArray(result);

ax = new MWNumericArray(x, MWClassID.DOUBLE);

ay = new MWNumericArray(y, MWClassID.DOUBLE);

polyFit = new PolyFit();

result=polyFit.Plot(ax,ay);

polyFit.waitForFigures();

} catch (Exception e) {

System.out.println("Exception: " + e.toString());

}

finally {

// 释放本地资源

MWArray.disposeArray(a);

MWArray.disposeArray(ax);

MWArray.disposeArray(ay);

MWArray.disposeArray(result);

getEig.dispose();

getMagic.dispose();

polyFit.dispose();

}

}

}

㈡ matlab与java混合编程报错

: 这个是字符串操作越界了,检查一下代码,是不是有substring这样的操作,应该是这样引起的

㈢ matlab java 混合编程,报的错Error using NaN Trailing string input must be 'single' or 'double'

参数传递错误,导致原来是传递正确的数字类型、变成传递空/null字符串了

㈣ MATLAB怎么学呢

一,MATLAB功能非常全面,也非常强大,
主要用于科学计算,它的计算基于矩阵来实现,可用于以下方面:
1,数值计算(好多问题没有解析解);
2,符号计算(呵呵,很强悍,做高数题方便了,不过在这方面MATLAB还不
是相当强,它的符号计算库借用了Maple的);
3,数据的分析,处理及可视化(数据绘图很方便);
4,图形图像处理,信号分析处理等等;
5,Simulink建模仿真,这是MATLAB非常有特色也是非常强大的功能,也使得其应用不仅仅局限于一般的科学计算。
二,MATLAB的软件应用:
MATLAB是用C语言开发的,支持编程,而且其语法跟C语言很相似,楼主想必已经学过C语言,再学习MATLAB会很轻松。
MATLAB支持与C语言,Fortran语言,Java语言的混合编程,同时支持与word,excel的混合使用,扩展性强。
三,MATLAB的学习:
学习它首先要有比较好的教材,初级阶段就用比较简单的教材,清华的,北航的,都可以。
高级阶段要用比较厚重,全面的教材,推荐一本鄙人正在使用的教材,人们邮电出版社出版,求是科技编着的《MATLAB
7.0
从入门到精通》,还有一本国内翻译的由美国人写的教材,很厚,很全(楼主自己在网上搜一下,我见同系的同学拿过,还是相当不错的)。
另外,学习MATLAB跟学习其他语言一样,要多上机,多练习,熟能生巧嘛。最后祝楼主学习愉快。
以上系个人总结,有啥不妥之处,还请见谅啊(看在我码这么多字的份上,也该奖励一下吧,呵呵)。

㈤ 求C语言教程和JAVA教程

资料内容所涉及方面:
C/C++/VC++的基础教程、通讯、协议分析、游戏开发、图像处理、管理系统、多媒体、加密与解密、控件ACTIVEX、开发CGI、标准程式库、技术内幕、Windows核心编程、对象模型、人工智能、软件工程、数据结构、WindowsAPI、Visual Basic 、Directx、网络开发、数据库开发、ADO、神经网络、DLL和内存管理、OLE&DDE、操作系统、端口、数值算法、等等技术或相关开发资料。
《C语言专区》
C语言实例教程 1.72
http://download.chinaitlab.com/soft/8658.htm

经典编程900例(C语言)
http://download.chinaitlab.com/soft/7972.htm

C语言实例教程
http://download.chinaitlab.com/soft/6530.htm

C语言图象处理方法
http://download.chinaitlab.com/soft/6514.htm

C语言编程实例
http://download.chinaitlab.com/soft/6103.htm

C语言书打包下载
http://download.chinaitlab.com/soft/6041.htm

集成学习环境(C语言)
http://download.chinaitlab.com/soft/5764.htm

C语言圣经 1.0
http://download.chinaitlab.com/soft/5745.htm

用C实现面向对象
http://download.chinaitlab.com/soft/7566.htm

C语言高级实用编程技巧
http://download.chinaitlab.com/soft/4593.htm

C语言最新编程技巧200例
http://download.chinaitlab.com/soft/4594.htm

C语言速成3.0
http://download.chinaitlab.com/soft/4723.htm

C语言编程技巧程序集
http://download.chinaitlab.com/soft/4561.htm

C语言速成多媒件课件 3.0
http://download.chinaitlab.com/soft/3238.htm

C语言多媒体教程
http://download.chinaitlab.com/soft/2893.htm

C程序设计培训
http://download.chinaitlab.com/soft/6340.htm

实用C语言详解
http://download.chinaitlab.com/soft/3274.htm

C语言程序设计及应用实例
http://download.chinaitlab.com/soft/3241.htm

C语言程序宝典
http://download.chinaitlab.com/soft/3071.htm

C语言教程
http://download.chinaitlab.com/soft/3027.htm

《C语言编程宝典》
http://download.chinaitlab.com/soft/1849.htm

C语言常用函数手册
http://download.chinaitlab.com/soft/1818.htm

C语言学习系统
http://download.chinaitlab.com/soft/1816.htm

C语言技术文章
http://download.chinaitlab.com/soft/1817.htm

C常用算法程序集
http://download.chinaitlab.com/soft/6225.htm

微软C编程精粹
http://download.chinaitlab.com/soft/6166.htm

《C++语言专区》

Inside C++ Object Model
http://download.chinaitlab.com/soft/7851.htm

C++ 入门基础教程
http://download.chinaitlab.com/soft/7617.htm

C++和面向对象的数值计算
http://download.chinaitlab.com/soft/6987.htm

经典C++语言教程
http://download.chinaitlab.com/soft/7399.htm

C++编程实例详解
http://download.chinaitlab.com/soft/6988.htm

C_C++深层探索
http://download.chinaitlab.com/soft/6989.htm

C_C++程序设计
http://download.chinaitlab.com/soft/6990.htm

C++输入输出流及本地化
http://download.chinaitlab.com/soft/6986.htm

经典 C++语言教程
http://download.chinaitlab.com/soft/6978.htm

C++ Primer 3rd Edition
http://download.chinaitlab.com/soft/6823.htm

C++_Primer_Plus_4th
http://download.chinaitlab.com/soft/6819.htm

C++应用编程200例
http://download.chinaitlab.com/soft/6820.htm

C++面向对象高效编程
http://download.chinaitlab.com/soft/6610.htm

Borland C++ 3.0自学培训教程
http://download.chinaitlab.com/soft/6274.htm

经典 C++ 语言教程
http://download.chinaitlab.com/soft/6600.htm

C++Builder自学培训教程
http://download.chinaitlab.com/soft/6317.htm

Borland C++ Builder高级编程
http://download.chinaitlab.com/soft/7927.htm

高质量C_C++编程指南
http://download.chinaitlab.com/soft/7916.htm

C++程序设计培训教程
http://download.chinaitlab.com/soft/6339.htm

C++程序设计教程
http://download.chinaitlab.com/soft/6338.htm

C++Builder核心program
http://download.chinaitlab.com/soft/6318.htm

C++Builder基础进阶
http://download.chinaitlab.com/soft/6316.htm

C++Builder30开发指南

创世纪的C++ Builder教程
http://download.chinaitlab.com/soft/6175.htm

http://download.chinaitlab.com/soft/6311.htm

21天学会C++
http://download.chinaitlab.com/soft/6307.htm

C++程序调试实用手册
http://download.chinaitlab.com/soft/6131.htm

C++Builder学习大全中文版
http://download.chinaitlab.com/soft/6077.htm

C&C++深层探索
http://download.chinaitlab.com/soft/6036.htm

C++ 设计新思维
http://download.chinaitlab.com/soft/6037.htm

经典C++图书下载 1
http://download.chinaitlab.com/soft/6067.htm

经典C++图书下载 2
http://download.chinaitlab.com/soft/6068.htm

C++ 常见问题问与答
http://download.chinaitlab.com/soft/6005.htm

C++ 和面向对象的数值计算
http://download.chinaitlab.com/soft/6006.htm

C++ 面向对象多线程编程
http://download.chinaitlab.com/soft/6007.htm

嵌入式系统中C的开发
http://download.chinaitlab.com/soft/6027.htm

用 C++ 开发 Web 商用程序
http://download.chinaitlab.com/soft/6033.htm

C++名家对话
http://download.chinaitlab.com/soft/5981.htm

C++实践之路
http://download.chinaitlab.com/soft/6040.htm

C++bulider参考手册 1.1
http://download.chinaitlab.com/soft/6574.htm

用C++开发Web商用程序
http://download.chinaitlab.com/soft/6975.htm

C++代码设计与重用
http://download.chinaitlab.com/soft/5980.htm

C++程序设计讲义
http://download.chinaitlab.com/soft/5742.htm

《C#语言专区》

C# Primer Plus中文版
http://download.chinaitlab.com/soft/7990.htm

C# 开发编码规范
http://download.chinaitlab.com/soft/7991.htm

C#深入浅出全接触
http://download.chinaitlab.com/soft/6992.htm

C# COM+ Programming
http://download.chinaitlab.com/soft/7855.htm

Design Pattern In C#
http://download.chinaitlab.com/soft/7852.htm

C#实现的俄罗斯方块程序
http://download.chinaitlab.com/soft/7805.htm

C#高级编程第2版
http://download.chinaitlab.com/soft/6883.htm

C#百例
http://download.chinaitlab.com/soft/7638.htm

C#.NET 开发者手册
http://download.chinaitlab.com/soft/7620.htm

CSharp程序员参考手册
http://download.chinaitlab.com/soft/7618.htm

C#程序100实例
http://download.chinaitlab.com/soft/7619.htm

新一代C#与ASP.NET权威指南
http://download.chinaitlab.com/soft/4115.htm

C#与.NET技术平台实演练
http://download.chinaitlab.com/soft/4044.htm

C#程序员参考手册
http://download.chinaitlab.com/soft/6991.htm

C# Network Programming
http://download.chinaitlab.com/soft/7484.htm

C#入门经典
http://download.chinaitlab.com/soft/6570.htm

ASP.NET C#教程
http://download.chinaitlab.com/soft/6640.htm

C#.NET中文版Web服务开发基础
http://download.chinaitlab.com/soft/3691.htm

精通C#与ASP.NET程序设计
http://download.chinaitlab.com/soft/6578.htm

C#文档中文版(微软)
http://download.chinaitlab.com/soft/1839.htm

C#教程
http://download.chinaitlab.com/soft/3070.htm

C#高级编程
http://download.chinaitlab.com/soft/1841.htm

C#进阶手册
http://download.chinaitlab.com/soft/1596.htm

MS Press Inside C#
http://download.chinaitlab.com/soft/4306.htm

C#实例程序
http://download.chinaitlab.com/soft/5586.htm

Windows应用高级编程-C#编程篇
http://download.chinaitlab.com/soft/4992.htm

C#与.NET技术平台实战演练
http://download.chinaitlab.com/soft/4813.htm

C#语言参考
http://download.chinaitlab.com/soft/4814.htm

C#.NET编程培训教程
http://download.chinaitlab.com/soft/6331.htm

C# WINDOWS程序设计
http://download.chinaitlab.com/soft/6097.htm

C#系列教程
http://download.chinaitlab.com/soft/6099.htm

C#英文手册
http://download.chinaitlab.com/soft/5929.htm

精通C#简体中文版
http://download.chinaitlab.com/soft/6552.htm

C# 参考手册
http://download.chinaitlab.com/soft/6374.htm

C#语言规范
http://download.chinaitlab.com/soft/6375.htm

C# 程序员介绍
http://download.chinaitlab.com/soft/6356.htm

C# 程序员参考手册
http://download.chinaitlab.com/soft/6388.htm

C#--微软.NET的第一语言
http://download.chinaitlab.com/soft/6376.htm

C#基本书写规范技术文档
http://download.chinaitlab.com/soft/5660.htm

《VC++语言专区》

VC++与Matlab混合编程的快速实现
http://download.chinaitlab.com/soft/7848.htm

VC++编程指南
http://download.chinaitlab.com/soft/7475.htm

VC++6编程方法
http://download.chinaitlab.com/soft/6352.htm

VC++6.0 类库参考手册
http://download.chinaitlab.com/soft/6345.htm

VC++database编程大全
http://download.chinaitlab.com/soft/6348.htm

VC++6.0培训教程
http://download.chinaitlab.com/soft/6351.htm

VC++编程技巧与范例
http://download.chinaitlab.com/soft/6349.htm

VC++网络教程
http://download.chinaitlab.com/soft/6350.htm

VC++面向对象入门
http://download.chinaitlab.com/soft/6346.htm

VC++扩展编程实例
http://download.chinaitlab.com/soft/6159.htm

用VC++编写USB接口通信程序
http://download.chinaitlab.com/soft/6073.htm

VC++6.0 语言参考手册
http://download.chinaitlab.com/soft/5956.htm

VC++6.0内幕
http://download.chinaitlab.com/soft/5959.htm

VC++6.0 运行库参考手册
http://download.chinaitlab.com/soft/5957.htm

VC++5.0易学活用
http://download.chinaitlab.com/soft/5954.htm

VC++6.0 用户界面制作技术与应用实例
http://download.chinaitlab.com/soft/5955.htm

Visual C++6.0从入门到精通
http://download.chinaitlab.com/soft/8645.htm

Visual C++ 6.0 教程
http://download.chinaitlab.com/soft/7974.htm

Visual C++ 6.0 开发宝典
http://download.chinaitlab.com/soft/7973.htm

Visual C++ 6.0实例
http://download.chinaitlab.com/soft/7970.htm

VISUAL C++扩展编程实例
http://download.chinaitlab.com/soft/7606.htm

Visual C++6.0高级编程技巧与实例
http://download.chinaitlab.com/soft/7607.htm

Visual C++ 6.0用户开发手册
http://download.chinaitlab.com/soft/7593.htm

疯狂VC技巧集
http://download.chinaitlab.com/soft/5688.htm

VC模板库手册
http://download.chinaitlab.com/soft/5960.htm

用VC开发Activex
http://download.chinaitlab.com/soft/5969.htm

用VC开发CGI
http://download.chinaitlab.com/soft/5970.htm

用VC开发win应用
http://download.chinaitlab.com/soft/5971.htm

VC通讯
http://download.chinaitlab.com/soft/5964.htm

VC入门教程
http://download.chinaitlab.com/soft/5961.htm

VC实例
http://download.chinaitlab.com/soft/5962.htm

VC使用大全
http://download.chinaitlab.com/soft/5963.htm

VC5.0开发人员参考手册
http://download.chinaitlab.com/soft/5952.htm

跟我学 VISUAL C++ 6.0
http://download.chinaitlab.com/soft/7592.htm

精通Visual C++图像编程
http://download.chinaitlab.com/soft/7590.htm

Visual C++.NET应用编程150例
http://download.chinaitlab.com/soft/7396.htm

Visual C++ 6.0 高级编程
http://download.chinaitlab.com/soft/6802.htm

Visual C++ 6—24学时学习教程
http://download.chinaitlab.com/soft/6582.htm

Visual C++高级编程技巧与实例
http://download.chinaitlab.com/soft/6554.htm

Visual C++ 设计WIN32应用程序
http://download.chinaitlab.com/soft/6555.htm

Visual C++ 6.0 编程实例与技巧
http://download.chinaitlab.com/soft/6449.htm

Visual C++ 6.0 程序员指南
http://download.chinaitlab.com/soft/6275.htm

Visual C++ 6-24学时学习教程
http://download.chinaitlab.com/soft/6223.htm

Visual C++ - Visual C++
http://download.chinaitlab.com/soft/6063.htm

Visual C++ .net多媒体教学
http://download.chinaitlab.com/soft/1069.htm
VC编程经验总结
http://download.chinaitlab.com/soft/6160.htm

VC新手学堂
http://download.chinaitlab.com/soft/6090.htm

VC6.0 MFC类库参考手册
http://download.chinaitlab.com/soft/6357.htm

VC6.0 运行库参考手册
http://download.chinaitlab.com/soft/6355.htm

VC-MFC编程实例
http://download.chinaitlab.com/soft/6354.htm

VC-MFC扩展编程实例
http://download.chinaitlab.com/soft/6353.htm

深入VC编程内幕
http://download.chinaitlab.com/soft/6473.htm

Visual C.NET中文版Web服务开发基础
http://download.chinaitlab.com/soft/6976.htm

然后还有个C语言网络吧:
http://post..com/f?kz=5728013

参考资料:http://www.programfan.com/blog/article.asp?id=6925

㈥ MATLAB JAVA混合编程效率问题

因为java在打包成为字节码后是被jvm解释执行的。

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:746
制作脚本网站 发布:2025-10-20 08:17:34 浏览:1009
python中的init方法 发布:2025-10-20 08:17:33 浏览:715
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:876
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:774
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1124
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:349
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:227
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:911
python股票数据获取 发布:2025-10-20 07:39:44 浏览:873