matlab版本R2014a gcc原来版本4.8.4
matlab不支持。
matlab最高支持4.7(包括R2015版本也是一样)
1 用sudo apt-get install gcc-4.7安装gcc4.7 同样安装gfortran-4.7 g++4.7
2 sudo vi /usr/local/MATLAB/R2014a/bin/mexopts.sh 把gcc g++ gfortran的地方加后缀-4.7,注意是-4.7 没有‘-’是不行的。
3 sudo cp /usr/local/MATLAB/R2014a/bin/mexopts.sh /home/mri/.matlab/R2014a/mexopts.sh 拷贝到这个目录 /mri是我电脑目录 根据你自己的目录改这个名字。
4 sudo matlab 打开matlab
5 在matlab命令行窗口
打如下命令
mex -setup
matlab有如下显示:
The options files available for mexsh are:
1: /usr/local/MATLAB/R2014a/bin/mexopts.sh :
Template Options file for building MEX-files
0: Exit with no changes
Enter the number of the compiler (0-1):
然后键入1
Overwrite /home/mri/.matlab/R2014a/mexopts.sh ([y]/n)?
输入 y
/usr/local/MATLAB/R2014a/bin/mexopts.sh is being copied to
/home/mri/.matlab/R2014a/mexopts.sh
完成即可。
我的电脑按照此步骤可以运行了。