版本R2016a,在使用minmax_install工具時出現:
錯誤使用 getmexopts (line 36)
getmexopts [Bruno]: cannot open comopts.bat file出錯 minmax_install (line 20)
compiler = getmexopts('COMPILER');
進入getmexopts函數,看到調用程序如下:
if ispc()
optpath=prefdir;
optfile=[optpath filesep 'comopts.bat'];
mexoptfile=[optpath filesep 'mexopts.bat'];
原因分析:prefdir指向了“C:\Users\*****\AppData\Roaming\MathWorks\MATLAB\R2016a”這樣的路徑,但是找不到comopts.bat文件,所以報錯。
解決方案:在Mathwork中官方找到了解釋:在Matlab2014a以後的版本就刪除了comopts.bat這個文件,解決方法下載最新的minmax_install工具箱:MinMaxSelection下載,最新版在2016年針對這個問題更新過。
新舊版本對比如下:(紅色部分爲新版本加入的判斷條件)
if ispc() && datenum(version('-date')) < datenum('January 11, 2014')
compiler = getmexopts('COMPILER');
islcc = strcmpi(compiler,'lcc');
如果檢測到版本在2014之後,就不會執行下面的getmexopts調用。用最新的工具箱就沒問題了。