将matlab数组(MAT文件)转换为C ++数组: [英] Converting a matlab array (MAT-file) to C++ array:

查看:844
本文介绍了将matlab数组(MAT文件)转换为C ++数组:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a 2-D double-precision array in MATLAB that contains specific data. I want to open and use this array in my c++ program, in the first step I save it in a mat-file. 





我的尝试:





What I have tried:

I know that MATLAB has some c functions that provide reading mat-file in c++ (matdsgn , matOpen , ...), but I have no idea how to use these functions in a c++ program. Actually, I don't know how to use a C library in C++. Any help would be appreciated.

推荐答案

可以直接从C ++程序调用C库函数。例如:

C library functions can be called directly from a C++ program. For example:
#include <math.h>

double foo(double value, int power)
{
    double answer = pow(value, (double)power);

// other code gor this method

    return answer;
}





matlab文档是查找转换函数的地方。



The matlab documentation is the place to look for conversion functions.


要在C ++中使用C库,只需将应用程序与库链接,并在源文件或头文件中包含库头文件,这些文件从库中调用函数或使用库头文件中定义的类型。



根据 MAT文件库和包含文件 - MATLAB& Simulink - MathWorks英国 [ ^ ]只有共享库版本。因此,您必须将它们与您的应用程序一起分发。
To use a C library with C++ just link your application with the library and include the library header file(s) in your source or header files that call functions from the library or use types defined in the library header files.

According to MAT-File Library and Include Files - MATLAB & Simulink - MathWorks United Kingdom[^] there are only shared library versions. So you have to distribute them with your application.


这篇关于将matlab数组(MAT文件)转换为C ++数组:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆