【问题标题】:Port Matlab code to C++ having .mat dataset将 Matlab 代码移植到具有 .mat 数据集的 C++
【发布时间】:2013-12-04 13:15:53
【问题描述】:

我正在尝试将一个.mat 文件导出为hd5 格式的数据类型为struc 存储的数据,以使其与使用coder 的c++ 移植兼容。但是hd5 只接受数值。代码给出以下错误-

Error using ==> h5write at 54 Argument 'Data' failed validation isnumeric.

虽然这是我的代码,但我不确定我是否正确使用它

h5write('myfile.h5','/model/filters',model.filters,1,146); 

也尝试过,但遇到了同样的错误 -

h5write('myfile.h5','/model/filters','face_p146_small.mat',1,146);

我的疑问继续我之前的问题here。 非常感谢有关将代码从 Matlab 移植到具有 .mat 文件格式数据的 C++ 的任何帮助。

【问题讨论】:

  • 那么您是否绝对确定 Matlab 的 C 编译器不会即时完成这项工作,以至于您需要滚动自己的 C 代码?
  • @phoeagon yup..我得到了stackoverflow.com/q/20088797/1958635 中提到的错误,也是基于我在那个问题上得到的答案。
  • 如前所述 here coder.extrinsic 不能使用,除非创建 MEX 文件。
  • 您是否希望 matio 读取 .mat 文件而不是 h5 ?
  • @AlexandreBizeau 我之前研究过mation,我认为使用matio 只会让我无法读取.mat 文件,但不能将matlab 代码移植到c++。我必须手动完成..我正确吗?

标签: c++ matlab porting face-detection hdf5


【解决方案1】:

最后我找到了我的方案的答案。由于我使用的算法使用了非常复杂的数据,我需要使用二进制数据格式,但不支持将 Matlab 支持的所有二进制数据格式转换/移植到 C++。

Matlab 代码转换为 C++ 支持的所有函数列表

http://www.mathworks.in/help/simulink/ug/functions-supported-for-code-generation--alphabetical-list.html

Matlab 支持的数据格式列表

http://www.mathworks.in/help/matlab/import_export/supported-file-formats.html

matlab支持的函数数据格式好像都不支持转换。

所以我肯定要重写代码

【讨论】:

    猜你喜欢
    • 2015-06-18
    • 2011-09-28
    • 2015-02-21
    • 2013-02-06
    • 2014-04-24
    • 2011-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多