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. C语言 对称矩阵 压缩 实现

    对称矩阵压缩的简单实现 (GCC编译). /** * @brief C语言 对称矩阵 压缩 实现 * @author wid * @date 2013-11-03 * * @note 若代码存在 bu ...

  2. 通用对象池ObjectPool的一种简易设计和实现方案

    对象池,最简单直接的作用当然是通过池来减少创建和销毁对象次数,实现对象的缓存和复用.我们熟知的线程池.数据库连接池.TCP连接池等等都是非常典型的对象池. 一个基本的简易对象池的主要功能实现我认为应该 ...

  3. Redis教程(九):主从复制配置实例

    转载于:http://www.itxuexiwang.com/a/shujukujishu/redis/2016/0216/136.html 一.Redis的Replication: 这里首先需要说明 ...

  4. Java程序员的日常 —— 《编程思想》包和访问权限

    包的作用 在C++中有命名空间的概念,这是因为,不同的项目或者人写出来的代码,可能名称是一样的.比如,java.util中有List,java.awt中也有List,那么我们在开发中,怎么会知道使用的 ...

  5. podspec文件介绍

    podspec文件是cocopods引入的第三方代码库的配置索引文件 它的创建命令是:$pod spec create TestFile podspec文件的常用配置字段介绍 Pod::Spec.ne ...

  6. asp.net webAPI 自动生成帮助文档并测试

    之前在项目中有用到webapi对外提供接口,发现在项目中有根据webapi的方法和注释自动生成帮助文档,还可以测试webapi方法,功能很是强大,现拿出来与大家分享一下. 先看一下生成的webapi文 ...

  7. atitit.文件上传带进度条的实现原理and组件选型and最佳实践总结O7

    atitit.文件上传带进度条的实现原理and组件选型and最佳实践总结O7 1. 实现原理 1 2. 大的文件上传原理::使用applet 1 3. 新的bp 2 1. 性能提升---分割小文件上传 ...

  8. Windows 10 Java环境变量配置

    Win10下 Java环境变量配置 首先,你应该已经安装了 Java 的 JDK 了(如果没有安装JDK,请跳转到此网址:http://www.oracle.com/technetwork/java/ ...

  9. SAE部署django应用

    最近自己动手实现了一个博客系统,使用基于python的web框架django,运行在SAE上.以下是遇到的问题,特总结如下: 1, SAE支持的django等第三方模块的版本如下: http://ww ...

  10. gridlaylout 简单布局

    package com.example.gridlayout; import android.app.Activity; import android.os.Bundle; import androi ...