linux下 C++ 读取mat文件 MATLAB extern cyphon scipy 未完待续
1.使用Matlab的C扩展,需要用户安装matlab。
g++ -L/media/exsoftware/MATLAB/R2013b/bin/glnxa64 -Wl,-rpath,/media/exsoftware/MATLAB/R2013b/bin/glnxa64 -o "test" ./d.o ./testmat.o -lmat -lmx
g++ compiler:
include:
/media/exsoftware/MATLAB/R2013b/extern/include
ECLIPSE SETTING:
Linker
library:
-L /media/exsoftware/MATLAB/R2013b/bin/glnxa64
-lmat -lmx
miscellaneous, Linker flags:
-Wl,-rpath,/media/exsoftware/MATLAB/R2013b/bin/glnxa64
/*
* MAT-file diagnose program
*
* See the MATLAB API Guide for compiling information.
*
* Calling syntax:
*
* matdgns <matfile>
*
* It will diagnose the MAT-file named <matfile>.
*
* This program demonstrates the use of the following functions:
*
* matClose
* matGetDir
* matGetNextVariable
* matGetNextVariableInfo
* matOpen
*
* Copyright 1984-2003 The MathWorks, Inc.
*/
/* $Revision: 1.8.4.1 $ */
#include <stdio.h>
#include <stdlib.h>
#include "mat.h" int diagnose(const char *file) {
MATFile *pmat;
const char **dir;
const char *name;
int ndir;
int i;
mxArray *pa; printf("Reading file %s...\n\n", file); /*
* Open file to get directory
*/
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error opening file %s\n", file);
return();
} /*
* get directory of MAT-file
*/
dir = (const char **)matGetDir(pmat, &ndir);
if (dir == NULL) {
printf("Error reading directory of file %s\n", file);
return();
} else {
printf("Directory of %s:\n", file);
for (i=; i < ndir; i++)
printf("%s\n",dir[i]);
}
mxFree(dir); /* In order to use matGetNextXXX correctly, reopen file to read in headers. */
if (matClose(pmat) != ) {
printf("Error closing file %s\n",file);
return();
}
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error reopening file %s\n", file);
return();
} /* Get headers of all variables */
printf("\nExamining the header for each variable:\n");
for (i=; i < ndir; i++) {
pa = matGetNextVariableInfo(pmat, &name);
if (pa == NULL) {
printf("Error reading in file %s\n", file);
return();
}
/* Diagnose header pa */
printf("According to its header, array %s has %d dimensions\n",
name, int( mxGetNumberOfDimensions(pa)));
if (mxIsFromGlobalWS(pa))
printf(" and was a global variable when saved\n");
else
printf(" and was a local variable when saved\n");
mxDestroyArray(pa);
} /* Reopen file to read in actual arrays. */
if (matClose(pmat) != ) {
printf("Error closing file %s\n",file);
return();
}
pmat = matOpen(file, "r");
if (pmat == NULL) {
printf("Error reopening file %s\n", file);
return();
} /* Read in each array. */
printf("\nReading in the actual array contents:\n");
for (i=; i<ndir; i++) {
pa = matGetNextVariable(pmat, &name);
if (pa == NULL) {
printf("Error reading in file %s\n", file);
return();
}
/*
* Diagnose array pa
*/
printf("According to its contents, array %s has %d dimensions\n",
name, int(mxGetNumberOfDimensions(pa)));
if (mxIsFromGlobalWS(pa))
printf(" and was a global variable when saved\n");
else
printf(" and was a local variable when saved\n");
mxDestroyArray(pa);
} if (matClose(pmat) != ) {
printf("Error closing file %s\n",file);
return();
}
printf("Done\n");
return();
} int main(int argc, char **argv)
{ int result; if (argc > )
result = diagnose(argv[]);
else{
result = ;
printf("Usage: matdgns <matfile>");
printf(" where <matfile> is the name of the MAT-file");
printf(" to be diagnosed\n");
} return (result==)?EXIT_SUCCESS:EXIT_FAILURE; }
2. 使用Python的scipy,或者scipy
Now, you have a complete Python installation in your home directory. Pass -I /home/username/python/include to gcc when compiling to make it aware of Python.h. Pass -L /home/username/python/lib and -lpython2.7 when linking.
linux下 C++ 读取mat文件 MATLAB extern cyphon scipy 未完待续的更多相关文章
- linux下为目录和文件设置权限
摘:linux下为目录和文件设置权限 分类: Linux2012-05-09 03:18 7456人阅读 评论(1) 收藏 举报 linuxwordpressweb数据库serverfile linu ...
- python读取mat文件
一.mat文件 mat数据格式是Matlab的数据存储的标准格式.在Matlab中主要使用load()函数导入一个mat文件,使用save()函数保存一个mat文件.对于文件 load('data.m ...
- python 读取.mat文件
导入所需包 from scipy.io import loadmat 读取.mat文件 随便从下面文件里读取一个: m = loadmat('H_BETA.mat') # 读出来的 m 是一个dict ...
- python中读取mat文件
mat数据格式是Matlab的数据存储的标准格式 在python中可以使用scipy.io中的函数loadmat()读取mat文件. import scipy.io as scio path = 'e ...
- linux下生成core dump文件方法及设置
linux下生成core dump文件方法及设置 from:http://www.cppblog.com/kongque/archive/2011/03/07/141262.html core ...
- Java读取mat文件
概述 使用ujmp中的jmatio模块读取.mat文件到java程序中. 其实,ujmp主要是在模块core中实现了矩阵运算,其余模块都是复用了已有的开源库.模块jmatio是复用了已有的JMatIo ...
- linux下恢复误删除的文件方法(ext2及ext3)
linux下恢复误删除的文件方法(ext2及ext3) 2009-12-19 15:23:47 分类: LINUX 如果是ext2文件系统的,直接用debugfs是可以恢复出来的,但对于ext3,d ...
- linux下分卷tar.bz文件的合并并解压缩
linux下分卷tar.bz文件的合并并解压缩 例: linux.tar.bz2.001;linux.tar.bz2.002;linux.tar.bz2.003; 首先 cat linux.tar.b ...
- linux下php上传文件注意
linux下php上传文件注意1.修改上传目录权限linux 修改某目录下所有所有子目录权限chmod -R 777 html修改某目录为任何用户都用写读执行权限chmod a+rwx html2.设 ...
随机推荐
- thrift之TTransport层的堵塞的套接字I/O传输类TSocket
本节将介绍第一个实现具体传输功能的类TSocket,这个类是基于TCP socket实现TTransport的接口.下面具体介绍这个类的相关函数功能实现. 1.构造函数 分析一个类的功能首先看它的定义 ...
- javascript 日常总结
1. 将彻底屏蔽鼠标右键 oncontextmenu=”window.event.returnValue=false” < table border oncontextmenu=return(f ...
- ubuntu安装ftp服务器
ubuntu安装ftp服务器 1: 安装vsftpd ~$ sudo apt-get install vsftpd ubuntu10.10自己装了,这步省略. 2: 配置vsftpd 2.1 修改vs ...
- Origin的图片导出问题
很多会议投稿都会要求提交的pdf文件用的是type1字体,因为type1字体是矢量字体,无论怎么放大缩小都不会失真.一旦pdf里嵌入了其他非矢量字体,例如type3字体,就会通不过测试,一个典型的例子 ...
- Leetcode 7 Reverse Integer 数论
题意:将整数倒置,该题简单但是需要注意数据的范围,难得的好题. 如果出现1000000003或者-2000000003,倒置后的数超过int的范围,因此返回0,出现这种情况可以使用long long, ...
- Leetcode 172 Factorial Trailing Zeroes
给定一个数n 求出n!的末尾0的个数. n!的末尾0产生的原因其实是n! = x * 10^m 如果能将n!是2和5相乘,那么只要统计n!约数5的个数. class Solution { public ...
- Python核心编程(切片索引的更多内容)
# coding=utf8 s = 'abcde' i = -1 for i in range(-1, -len(s), -1): print(s[:i]) # 结果 ''' abcd abc ab ...
- VC基于消息的异步套接字
用WSAStartup,需要在StdAfx.h头文件中需要声明 #include #pragma comment(lib,"WS2_32.lib") 用AfxSocket ...
- Android ImageView圆形头像
转载自:http://m.oschina.net/blog/321024 Android ImageView圆形头像 图片完全解析 我们在做项目的时候会用到圆形的图片,比如用户头像,类似QQ.用户在用 ...
- 使用 nc (Netcat) 建立傳送資料的 socket server
原文:http://blog.longwin.com.tw/2012/02/nc-data-send-socket-server-2012/ 於 Debian / Ubuntu Linux 想要透過 ...