求助:关于混合编程的错误,用mex编译就出现 - MATLAB 应用发布
如何实现C语言与MATLAB接口,出现 E:\PROGRA~1\MATLAB\R2012\BIN\MEX.PL: Error: No file names given. .错误。这该怎么解决啊?
》mex-setup
Usage:
MEX sourcefile1 [... sourcefileN]
Use the -help option for more information, or consult the MATLAB API Guide.
E:\PROGRA~1\MATLAB\R2012\BIN\MEX.PL: Error: No file names given.
Undefined function or variable 'setup'. 编译文件的时候后面要加上需要编译的文件的名字,貌似就是这个问题。Undefined function or variable 'setup'是不是mex后面没有加一个空格,你改成mex -setup试试 网上找到这个总结的不错,你可以借鉴!
在matlab上使用libsvm工具箱使用错误及解决方法汇总
首先附上使用过程
step1: 输入>>mex -setup
step2:
Please choose yourcompiler for building external interface (MEX) files:
Would you like mex to locate installed compilers /n? 是否让matlab自动检测编译器可以选y
step3:
Select a compiler:
Lcc-win32 C2.4.1 in E:\PROGRA~1\MATLAB\R2010a\sys\lcc
MicrosoftVisual C++ 2008 SP1 in e:\Program Files\Microsoft Visual Studio 9.0
MicrosoftVisual C++ 6.0 in E:\Program Files\Microsoft Visual Studio
None
matlab 自带的不能用 其他的如果有的话 就相应的选择就行
我选择了 【2】
step4:
Compiler: Microsoft Visual C++ 2008 SP1
Location:e:\Program Files\Microsoft Visual Studio 9.0
Are thesecorrect /n? 路径是否正确 是的就选y
如果没有自动检测出来依次的话step2就选【n】就可以,再顺着提示下来。
Step 5
Make
后面就是:
load heart_scale.mat(此处无分号)
train = heart_scale_inst;
train_label=heart_scale_label;
test=train;
test_label=train_label;
model=svmtrain(train_label,train,'-c 2 -g0.01');
=svmpredict(test_label,test,model);
1
make这一步报错
Error using mex (line 206)
Unable to complete successfully.
Error in make (line 1)
% This make.m is for MATLAB and OCTAVE
under Windows, Mac, and Unix
在尝试了许多方法后,竟然是换了低版本的libsvm,搞定了~~~
2 还有一个make这一步出现的错误3 Make时出错
Undefined function orvariable 'make'
解决方法为:
设置matlab的path
方法file->set path->set subpath(为什么要sub path因为只有这样才能将你要加的文件目录的子文件都加进去,否则只是加了你所要加的那个目录。)
还要记得把current folder 设为matlab所在的路径
3 输入load heart_scale.mat;报错
Error using load
Unable to read file heart_scale.mat;: No
such file or directory.
这个问题是这样的,不应该有最后那个; 去掉分号就可以了。。。(粗心所致。。。不知道别人会不会像我这样。。。)
4
load 这一步报错
??? Error using ==>load
Number of columns on line 2 of ASCII file D:\Program
Files\MATLAB2010\matlab\toolbox\libsvm-3.13\heart_scale
must be the same as previous lines.
官方现在不给heart_scale.mat,给的都是VC++下的格式。一些旧版本的工具箱还可以找到mat文件,新版本都没有了。所以load会报错:heart_scalemust be same as previous lines)
一种解决方法是:使用给的一个函数,转化数据。此函数为libsvmread()
使用如下: =libsvmread('filename');
此处为了跟官方统一名称可以 =libsvmread('heart_scale');
注意:由于heart_scale在libsvm-3.11目录下,不是在matlab下,所以直接用libsvmread命令会报错,要买改变当前路径,或者使用=libsvmread('../heart_scale');../代表返回上层路径。
但是最简单的方法是,找到旧版本工具箱的mat文件添加上即可!
5 到svmtrain这一步报错
??? Errorusing ==>svmtrain at 172
Group mustbe a vector.
是因为在添加工具箱的时候没有添加完全,file-Set Path-Add with Subfold ...添加好路径就可以了
在使用过程中到目前只遇到这些错误~现在也只是会简单的用libsvm工具箱……
页:
[1]