matlab安装LIBSVM

一.下载libsvm
http://www.csie.ntu.edu.tw/~cjlin/libsvm/
在libsvm的网站上下载 libsvm-3.12.zip文件,解压后放在任意目录下,最好放在MATLAB工具箱中,比如 C:\Program Files\MATLAB\R2011a\toolbox\libsvm-3.12下。

二。具体说说如何选择编译器。

  • 首先在MATLAB命令窗【Commond Window】中输入:mex -setup
Remark : 注意 mex 后面要打一个 空格 然后 是-setup。 千万别忘记打一个空格,发现好多朋友在mex和-setup之间没有打空格!!
  • 会出现类似如下内容:
Please choose your compiler for building external interface (MEX) files: 
Would you like mex to locate installed compilers [y]/n?
  • 这里问你是否locate本机安装的编译器,正规的选择y然后指定编译器即可,我们先来看一下选择y(选择n在后面说),好下面我们选择y。
  • 根据你本机安装的编译器,会出现类似如下内容:
Please choose your compiler for building external interface (MEX) files: 
Would you like mex to locate installed compilers [y]/n? y
Select a compiler: 
[1] Lcc-win32 C 2.4.1 in D:\MATLAB~1\sys\lcc 
[2] Microsoft Visual C++ 6.0 in D:\Microsoft Visual Studio 
[0] None 
Compiler:
  • 然后你选择相应的编译器并确认即可:
Compiler: 2
Please verify your choices: 
Compiler: Microsoft Visual C++ 6.0 
Location: D:\Microsoft Visual Studio 
Are these correct [y]/n? y
Trying to update options file: C:\Users\faruto\AppData\Roaming\MathWorks\MATLAB\R2009b\mexopts.bat
From template:              D:\MATLAB~1\bin\win32\mexopts\msvc60opts.bat 
Done . . .
PS:matlab支持的编译器列表在这里查看:
http://www.mathworks.com/support/compilers/current_release/
这样就表示编译器选择成功了(此步骤中可能会出现warning警告是正常现象,不用管的说~)。
  • 如果你输入 mex –setup后在
Please choose your compiler for building external interface (MEX) files: 
Would you like mex to locate installed compilers [y]/n?

  • 这一步选择y后,可选择的编译器里面有没你已经安装的编译器,表示MATLAB可能没有识别记录你安装的编译器的名字和目录(有时候会发生这种情况),此时你应该重新输入 mex –setup后选择n手动进行编译器的设置:
mex -setup
Please choose your compiler for building external interface (MEX) files: 
Would you like mex to locate installed compilers [y]/n? n
Select a compiler: 
[1] Intel C++ 9.1 (with Microsoft Visual C++ 2005 SP1 linker) 
[2] Intel Visual Fortran 10.1 (with Microsoft Visual C++ 2005 SP1 linker) 
[3] Lcc-win32 C 2.4.1 
[4] Microsoft Visual C++ 6.0 
[5] Microsoft Visual C++ .NET 2003 
[6] Microsoft Visual C++ 2005 SP1 
[7] Microsoft Visual C++ 2008 Express 
[8] Microsoft Visual C++ 2008 SP1 
[9] Open WATCOM C++ 
[0] None 
  • Compiler: 4  %选择的这个编译器一定是你本机安装了的,否则选择了也没有用
Your machine has a Microsoft Visual C++ compiler located at 
D:\Microsoft Visual Studio. Do you want to use this compiler [y]/n?
  • 这样的话就可以手动选择你想要的编译器了,在
Your machine has a Microsoft Visual C++ compiler located at 
D:\Microsoft Visual Studio. Do you want to use this compiler [y]/n?
  • 这个确认步骤,如果你的编译器的确是安装在MATLAB给出的这个目录(我这里是D:\Microsoft Visual Studio)那么选择y确认即可,如果不是说明MATLAB没有识别出安装的地方,选择n手动指定目录即可,比如选择n后的结果如下:
Compiler: 4
Your machine has a Microsoft Visual C++ compiler located at 
D:\Microsoft Visual Studio. Do you want to use this compiler [y]/n? n
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio]
  • 此时输入你安装的编译器的完整目录即可比如:D:\Microsoft Visual Studio
这样编译器的选择就结束了,相应会遇到的问题大概也就是上面这些了。




3. 编译文件(make)

这一步说白了就是运行一下 libsvm-mat工具箱中的make.m文件。
  • 首先需要把MATLAB的当前目录[Current Folder]调整到libsvm-mat所在的文件夹
  • 然后在MATLAB命令窗【Commond Window】输入make
如果成功运行没有报错,到此就说明libsvm-mat工具箱成功安装了。Libsvm-mat工具箱中有自带的heart_scale.mat测试数据集,可以运行以下代码来check一下是否安装成功:
load heart_scale;
model = svmtrain(heart_scale_label,heart_scale_inst);
[predict_label,accuracy] = svmpredict(heart_scale_label,heart_scale_inst,model);
如果出现下面这个结果,则说明肯定安装成功了:
Accuracy = 86.6667% (234/270) (classification)


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值