编译的 MATLAB 错误:“struct”类型的输入参数的未定义函数“ft_datatype_sens”

Posted

技术标签:

【中文标题】编译的 MATLAB 错误:“struct”类型的输入参数的未定义函数“ft_datatype_sens”【英文标题】:Compiled MATLAB error: Undefined function 'ft_datatype_sens' for input arguments of type 'struct' 【发布时间】:2017-06-21 12:19:41 【问题描述】:

我有一个使用 SPM8 工具箱的用户编写的 MATLAB 程序。如果直接运行,它工作正常。但是,编译再运行时,出现如下错误:

Undefined function 'ft_datatype_sens' for input arguments of type 'struct'

此功能来自与 SPM8 工具箱捆绑在一起的 Fieldtrip 工具箱。 startup.m 包含以下内容:

if(isdeployed==false)
    addpath(genpath('/cm/shared/apps/matlab/spm/08'))
    spm('defaults', 'eeg')
    spm_get_defaults('cmdline',true)
    disp('SPM path is set')
end

我自己不是 MATLAB 用户,我在黑暗中摸索,但我的假设是找不到 Fieldtrip 工具箱。

任何人都可以对此有所了解吗?

【问题讨论】:

已编译的应用程序不支持更改路径。如果您正在编译程序,请尝试使用 mcc 的“-C”标志来使用 zip 实用程序检查生成的包文件是否存在。 感谢您的提示。该包确实包含文件'ft_datatype_sens.m',所以看起来没问题。但是,我不明白您所说的“改变路径”是什么意思。路径不就是我在编译之前设置的,只是编译成独立的二进制文件吗?还是应该将外部工具箱移动到 MATLAB 安装的“工具箱”目录中? 如果文件在那里并且在编译之前添加了路径,它应该可以工作。不知道还有什么导致错误。我将从对工具箱的简单调用开始,以检查它是针对此功能还是针对整个工具箱。 【参考方案1】:

解决方案是需要通过选项-I明确给出必要的目录:

mcc -C -mv -R -singleCompThread -R -nodisplay -I /cm/shared/apps/matlab/spm/08/ -I /cm/shared/apps/matlab/spm/08/spm_orthviews -I /cm/shared/apps/matlab/spm/08/config -I /cm/shared/apps/matlab/spm/08/matlabbatch -I /cm/shared/apps/matlab/spm/08/matlabbatch/cfg_confgui -I /cm/shared/apps/matlab/spm/08/matlabbatch/cfg_basicio -I /cm/shared/apps/matlab/spm/08/matlabbatch/cfg_basicio/src -I /cm/shared/apps/matlab/spm/08/matlabbatch/examples -I /cm/shared/apps/matlab/spm/08/src -I /cm/shared/apps/matlab/spm/08/toolbox -I /cm/shared/apps/matlab/spm/08/toolbox/mixture -I /cm/shared/apps/matlab/spm/08/toolbox/spectral -I /cm/shared/apps/matlab/spm/08/toolbox/Seg -I /cm/shared/apps/matlab/spm/08/toolbox/Beamforming -I /cm/shared/apps/matlab/spm/08/toolbox/DEM -I /cm/shared/apps/matlab/spm/08/toolbox/DARTEL -I /cm/shared/apps/matlab/spm/08/toolbox/MEEGtools -I /cm/shared/apps/matlab/spm/08/toolbox/Neural_Models -I /cm/shared/apps/matlab/spm/08/toolbox/dcm_meeg -I /cm/shared/apps/matlab/spm/08/toolbox/SRender -I /cm/shared/apps/matlab/spm/08/toolbox/Shoot -I /cm/shared/apps/matlab/spm/08/toolbox/HDW -I /cm/shared/apps/matlab/spm/08/toolbox/FieldMap -I /cm/shared/apps/matlab/spm/08/EEGtemplates -I /cm/shared/apps/matlab/spm/08/canonical -I /cm/shared/apps/matlab/spm/08/rend -I /cm/shared/apps/matlab/spm/08/apriori -I /cm/shared/apps/matlab/spm/08/templates -I /cm/shared/apps/matlab/spm/08/external -I /cm/shared/apps/matlab/spm/08/external/fieldtrip -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/plotting -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/fileio -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/statfun -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/src -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/connectivity -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/inverse -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/specest -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/forward -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/utilities -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/preproc -I /cm/shared/apps/matlab/spm/08/external/fieldtrip/trialfun -I /cm/shared/apps/matlab/spm/08/external/yokogawa -I /cm/shared/apps/matlab/spm/08/external/eeprobe -I /cm/shared/apps/matlab/spm/08/external/mne -I /cm/shared/apps/matlab/spm/08/external/ctf -I /cm/shared/apps/matlab/spm/08/external/bemcp -I /cm/shared/apps/matlab/spm/08/tpm myprog.m

使用-a选项可以减少需要指定的目录数量,可以递归添加目录。

【讨论】:

以上是关于编译的 MATLAB 错误:“struct”类型的输入参数的未定义函数“ft_datatype_sens”的主要内容,如果未能解决你的问题,请参考以下文章

在matlab中,如何将struct类型转化为矩阵类型?

mex 编译错误:Matlab 数据类型和函数的预期表达式错误

matlab 如何读取struct里面的double数组?

vc2010的项目迁移到vc2019,解决编译错误问题

Matlab如何获得struct内元素的个数?

matlab怎样输出结构体数组