使用ujmp读取.mat文件
2015-12-22 16:31
381 查看
1)使用ujmp中的jmatio模块读取.mat文件到java程序中。
其实,ujmp主要是实现了矩阵运算,在模块core中。然后模块jmatio是复用了已有的JMatIo,对这个读取mat文件到java程序的库做了一层封装。从ujmp的官网(https://ujmp.org/)下载ujmp的jar包,但是这一个jar包并不能读取mat文件(虽然jar包内有jmatio模块),还需要下载一个JMatIo的jar包(http://pan.baidu.com/s/1jHpAtts)。将两个jar包都加入到工程中才可以从mat文件中顺利读取数据到java程序中。
操作过程如下:
2)在创建的工程中新建一个lib文件夹,将以上两个jar包拷贝到此文件夹中,必须要拷贝到项目中。比如,我之前是将两个jar包放在桌面上,但是当把jar包删除或移动之后,程序就不能运行了,很简单的道理。
3)加下来就是将两个jar包添加到工程中,以便在程序中使用这两个包中定义的类。
4)以下就是读取mat文件的代码:
参考:
http://www.programcreek.com/java-api-examples/index.php?api=com.jmatio.io.MatFileReader
https://www.kaggle.com/c/decoding-the-human-brain/forums/t/7862/using-jmatio/65560
http://blog.madhukaraphatak.com/matfile-to-rdd/
其实,ujmp主要是实现了矩阵运算,在模块core中。然后模块jmatio是复用了已有的JMatIo,对这个读取mat文件到java程序的库做了一层封装。从ujmp的官网(https://ujmp.org/)下载ujmp的jar包,但是这一个jar包并不能读取mat文件(虽然jar包内有jmatio模块),还需要下载一个JMatIo的jar包(http://pan.baidu.com/s/1jHpAtts)。将两个jar包都加入到工程中才可以从mat文件中顺利读取数据到java程序中。
操作过程如下:
2)在创建的工程中新建一个lib文件夹,将以上两个jar包拷贝到此文件夹中,必须要拷贝到项目中。比如,我之前是将两个jar包放在桌面上,但是当把jar包删除或移动之后,程序就不能运行了,很简单的道理。
3)加下来就是将两个jar包添加到工程中,以便在程序中使用这两个包中定义的类。
4)以下就是读取mat文件的代码:
/** * Created by hfz on 2015/12/22. */ import org.ujmp.jmatio.ImportMatrixMAT; import org.ujmp.core.Matrix; import java.io.File; import java.io.IOException; public class test{ public static void main(String[] args)throws IOException{ //相对路径的根目录是当前工程的目录(C:\Users\hfz\Desktop\test)。另外相对路径的起始处无“/” ImportMatrixMAT test=new ImportMatrixMAT(); File file=new File("data/A.mat"); Matrix testMatrix=test.fromFile(file); testMatrix.showGUI(); System.out.println("ss"); } }
参考:
http://www.programcreek.com/java-api-examples/index.php?api=com.jmatio.io.MatFileReader
https://www.kaggle.com/c/decoding-the-human-brain/forums/t/7862/using-jmatio/65560
http://blog.madhukaraphatak.com/matfile-to-rdd/
相关文章推荐
- think in java (com.bruceeckel.simpletest)配置
- DOM元素点击失效问题
- c++中关键字explicit用于类的构造函数
- Aerospike开发指南【中文】
- <LeetCode OJ>Valid Parentheses【20】
- 自己用java写了一款日志查找分析工具
- Postfix 故障记录
- 你不需要jQuery(二)
- Light oj 1047 - Neighbor House (简单dp)
- 编译安装httpd 2.4
- 【Android】SQLite实例(多线程下安全访问数据库)
- 基本数据类型转换以及时间格式化
- Infopath提示表单已经存在,怎么破?
- 【CSS3】边框--慕课网【学习总结】
- ccf-201412-2 Z字形扫描
- DOM属性及操作
- some characters cannot be mapped using"ISO-8859-1'/ GBK MYeclipse
- ubuntu 一键安装jdk 1.79
- Eclipse中快捷键的使用
- HI3518图像出现黄圈