Matlab 常见问题整理

本文总结一些在Linux 环境(ubuntu15.04 and redhat 6.5)下使用MATLAB常见的一些问题以及解决方案.

使用Matlab 在没有安装excel的linux,Mac以及win 系统环境上写数据到excel.

xlwrite: Generate XLS(X) files without Excel on Mac/Linux/Win.
解决方法来自:
http://www.mathworks.com/matlabcentral/fileexchange/38591-xlwrite--generate-xls-x--files-without-excel-on-mac-linux-win

具体例子如下:
% Small demonstration on how to use XLWRITE
% Initialisation of POI Libs
% Add Java POI Libs to matlab javapath

1
2
3
4
5
6
javaaddpath('poi_library/poi-3.8-20120326.jar');
javaaddpath('poi_library/poi-ooxml-3.8-20120326.jar');
javaaddpath('poi_library/poi-ooxml-schemas-3.8-20120326.jar');
javaaddpath('poi_library/xmlbeans-2.3.0.jar');
javaaddpath('poi_library/dom4j-1.6.1.jar');
javaaddpath('poi_library/stax-api-1.0.1.jar');

% Data Generation for XLSX
% Define an xls name

1
2
3
fileName = 'test_xlwrite.xlsx';
sheetName = 'this_is_sheetname';
startRange = 'B3';

% Generate some data

1
2
3
4
5
6
7
xlsData = {'A Number' 'Boolean Data' 'Empty Cells' 'Strings';...
1 true [] 'String Text';...
5 false [] 'Another very descriptive text';...
-6.26 false 'This should have been an empty cell but I made an error' 'This is text';...
1e8 true [] 'Last cell with text';...
1e3 false NaN NaN;...
1e2 true [] 'test'}

% Generate XLSX file

1
xlwrite(fileName, xlsData, sheetName, startRange);

I can’t open Matlab 2015a after I upgrade Ubuntu 14.10 to 15.04.

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar

This package is responsible for application menu support for Java swing applications, and seems to be the cause for the segfault. Removing it worked for me:

1
$ sudo apt-get remove jayatana

If you just want to remove the message you can just edit your $HOME/.bashrc (if using bash) or $HOME/.profile and unset the variable with: unset JAVA_TOOL_OPTIONS

1
2
3
4
$ echo 'unset JAVA_TOOL_OPTIONS' >> ~/.bashrc
$ echo 'unset JAVA_TOOL_OPTIONS' >> ~/.profile
$ source ~/.bashrc
$ source ~/.profile

MATLAB parallel error

Java exception occurred:
java.net.UnknownHostException: **: nodename nor servname provided, or not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1473)

When you type !hostname in the command window In Matlab, it returns a string. In /etc/hosts (OS X/Linux), you should add: 127.0.0.1 str (str being whatever string !hostname returned). Is this what you tried? I had the same issue and it worked for me. (in my case I added 127.0.0.1 server because my hostname is server) – Franck Dernoncourt Feb 2 at 4:17

matlab read CMYK image error

1
2
3
4
5
6
image_path='./Desktop/n01739381_1309.JPEG';
image_name='n01739381_1309.JPEG'
if strcmp(info(1,1).ColorType,'CMYK')
system(['convert ', image_path, ' -colorspace RGB', ' ./tmp/',image_name]);
image=imread(['./tmp/',image_name]);
end

Vlfeat Error in vl_demo_covdet (line 15)

Invalid MEX-file ‘/home/gaobb/mywork/toolbox/vlfeat-0.9.19/toolbox/mex/mexa64/vl_covdet.mexa64’:
/home/gaobb/mywork/toolbox/vlfeat-0.9.19/toolbox/mex/mexa64/libvl.so: undefined symbol: GOMP_parallel
Error in vl_demo_covdet (line 15)
frames = vl_covdet(imgs, ‘verbose’) ;

Solution
open the /vlfeat/makefile and edit:
Makefile DISABLE_OPENMP=yes

Vlfeat Error libvl.so: cannot open shared object file: No such file or directory

Invalid MEX-file ‘/home/gaobb/. mcrCache8.3/main_C0/home/gaobb/mywork/
toolbox/vlfeat- 0.9.20/toolbox/mex/mexa64/vl_fisher.mexa64’: libvl.so: cannot open shared object file: No such file or directory

Solution
Open the /etc/ld.so.conf as sudo and add a new line with the library directory. In this case, we add /home/gaobb/mywork/toolbox/vlfeat-0.9.20/toolbox/mex/mexa64
Rerun ldconfig to rebuild the cache:
sudo ldconfig
Check if the shared library cache now includes the shared libraries from the new directory:
ldconfig -p


本作品采用知识共享署名 2.5 中国大陆许可协议进行许可,欢迎转载,但转载请注明来自 Sunshine 并保持转载后文章内容的完整。本人保留所有版权相关权利。

本文链接:http://gaobb.github.io/2015/06/17/Matlab-常见问题整理/

坚持原创技术分享,您的支持将鼓励我继续创作!

热评文章