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 未完待续的更多相关文章

  1. linux下为目录和文件设置权限

    摘:linux下为目录和文件设置权限 分类: Linux2012-05-09 03:18 7456人阅读 评论(1) 收藏 举报 linuxwordpressweb数据库serverfile linu ...

  2. python读取mat文件

    一.mat文件 mat数据格式是Matlab的数据存储的标准格式.在Matlab中主要使用load()函数导入一个mat文件,使用save()函数保存一个mat文件.对于文件 load('data.m ...

  3. python 读取.mat文件

    导入所需包 from scipy.io import loadmat 读取.mat文件 随便从下面文件里读取一个: m = loadmat('H_BETA.mat') # 读出来的 m 是一个dict ...

  4. python中读取mat文件

    mat数据格式是Matlab的数据存储的标准格式 在python中可以使用scipy.io中的函数loadmat()读取mat文件. import scipy.io as scio path = 'e ...

  5. linux下生成core dump文件方法及设置

    linux下生成core dump文件方法及设置    from:http://www.cppblog.com/kongque/archive/2011/03/07/141262.html core ...

  6. Java读取mat文件

    概述 使用ujmp中的jmatio模块读取.mat文件到java程序中. 其实,ujmp主要是在模块core中实现了矩阵运算,其余模块都是复用了已有的开源库.模块jmatio是复用了已有的JMatIo ...

  7. linux下恢复误删除的文件方法(ext2及ext3)

     linux下恢复误删除的文件方法(ext2及ext3) 2009-12-19 15:23:47 分类: LINUX 如果是ext2文件系统的,直接用debugfs是可以恢复出来的,但对于ext3,d ...

  8. linux下分卷tar.bz文件的合并并解压缩

    linux下分卷tar.bz文件的合并并解压缩 例: linux.tar.bz2.001;linux.tar.bz2.002;linux.tar.bz2.003; 首先 cat linux.tar.b ...

  9. linux下php上传文件注意

    linux下php上传文件注意1.修改上传目录权限linux 修改某目录下所有所有子目录权限chmod -R 777 html修改某目录为任何用户都用写读执行权限chmod a+rwx html2.设 ...

随机推荐

  1. 在Win7 环境使用Java API 上传文件到 Hadoop2.x HDFS 问题统计

    问题一: org.apache.hadoop.security.AccessControlException: org.apache.hadoop.security .AccessControlExc ...

  2. UnicodeDecodeError while using json.dumps()

    UnicodeDecodeError 系统.文件.vim全部设置为utf-8 export LANG=zh_CN.UTF8 # coding:utf-8 json.dumps(content, ens ...

  3. [ucgui] 对话框5——鼠标位置和移动窗口

    >_<" 这节主要是获取鼠标的位置和把窗口设置为可以移动.其中设置窗口可以移动用FRAMEWIN_SetMoveable(hFrameWin, 1)就行了.而获得鼠标位置则是利用 ...

  4. js随机点名

    定时器案例. <!-- Author: XiaoWen Create a file: 2016-12-08 12:27:32 Last modified: 2016-12-08 12:51:59 ...

  5. JAVA学习Swing章节JPanel和JScrollPane面板的简单学习

    package com.swing; import java.awt.Container; import java.awt.GridLayout; import javax.swing.JButton ...

  6. 我所理解的JavaScript闭包

    目录 一.闭包(Closure) 1.1.什么是闭包? 1.2.为什么要用闭包(作用)? 1.2.1.保护函数内的变量安全. 1.2.2.通过访问外部变量,一个闭包可以暂时保存这些变量的上下文环境,当 ...

  7. 修復jquery的tablesorter对加了千分位的数字无法正确排序的bug

    找到函数: function getElementText(config, node) { var text = ""; if (!node) return "" ...

  8. C# 动态修改dll的签名 以及修改引用该dll文件的签名

    在读取RedisSessionStateProvider配置 提到用mono ceil 来修改程序集以及它的签名,里面GetPublicKey 和GetPubliKeyToken 方法里面那个字符串的 ...

  9. Puppet Openstack Mitaka Design Summit小结

    Puppet Openstack Design Summit小结 经过Puppet Openstack社区的不断努力,Puppet Openstack社区目前提供的Official Modules已经 ...

  10. mysql慢日志设置

    mysql的慢日志查询对于sql的优化还是很有意义的,具体说下如何开启这个mysql慢查询日志(默认是开启的). 关于设置在mysql的官方手册或网上都有很多,但是要注意的是,mysql5.6与之前的 ...