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.设 ...
随机推荐
- 学习WPF——了解路由事件
入门 我们先来看一个例子 前台代码: 后台代码: 点击按钮的运行效果第一个弹出窗口 第二个弹出窗口: 第三个弹出窗口: 说明 当点击按钮之后,先触发按钮的click事件,再上查找,发现stackpan ...
- AlwaysOn--查看可用性组的首先备份节点
在Alwayson中,可以通过设置来将备份放到指定的节点上完成,微软提供了函数用来判断当前指定节点进行备份: ) SET @database_name= 'DB5' SELECT CASE [mast ...
- 解决IIS Express 80端口被占用的情况
VS2012运行站点的时候提示“无法启动IIS Express Web服务器,端口80正在使用” 于是CMD查看了一下端口使用情况,并且在任务管理器中查看相应的进程,但始终觉得不对,因为显示是Syst ...
- webpy使用笔记(一)
webpy入门 工作环境中需要经常生产和测试服务器,机房一直很混乱,因此萌生了开发一个简单方便的服务器管理系统(说的好高大上,其实就是个可以获取服务器信息的小web应用).之所以选择webpy,正式因 ...
- Linux:Vim
模式介绍: Vim具备6种基本模式和5中派生模式. 普通模式 启动后的默认模式,用于:移动光标.删除文本等待,常用命令: dd:删除当前行. [number]dd:连续执行number对应次数的dd命 ...
- 分布式icinga2安装与使用
目标 配置分布式的icinga2监控系统.分布式监控适用于服务器遍布在多个区域,且需要一个master做统一管理. 搭建环境 服务器 系统: ubuntu 15.04/ubuntu 14.04 ici ...
- [Java拾遗二]Tomact及Http 部分总结.
前言: 刚好今天回来的很早, 总结下 Tomcat及Http的基础知识. 1, Tomcat web相关概念 web:网页的意思,网页资源包括服务器上的所有资源. ...
- python pycurl模块
一.pycurl概述 PycURl是一个C语言写的libcurl的python绑定库.libcurl 是一个自由的,并且容易使用的用在客户端的 URL 传输库.它的功能很强大,在PyCURL的主页上介 ...
- VS2010 win7 QT4.8.0,实现VS2010编译调试Qt程序,QtCreator静态发布程序
下载源代码,注意一定是源码压缩包如qt-everywhere-opensource-src-4.8.0.zip, 不是Qt发布的已编译的不同版本的标准库如qt-win-opensource-4.8.0 ...
- Unity3D去掉全屏时的屏幕黑边
给全屏后不在乎拉伸变形仍想让画面占满屏幕的朋友,网上搜了一上午,实在是没有相关的资料,只能自己琢磨了. 使用Canvas Scaler在全屏后Unity虽然会为我们自动拉伸UI,但拉伸后仍然保持我们在 ...