我有一个matlab函数,我从命令行调用:
matlab -nodisplay -nojvm -nosplash -nodesktop -r "matrix(10,'test')"
其中matrix.m
包含以下内容:
function y=matrix(N,name)
A = randn(N);
[Q, R] = qr(A);
clearvars A R
ind = randperm(N);
indMinus = ind(1:round(N/2));
diagonal = ones(1,N);
diagonal(indMinus) = -1;
L = diag(diagonal);
mt = Q*L*(Q');
clearvars Q L
fname = ['matrix',name,'.dat'];
fid = fopen(fname, 'w');
fprintf(fid,'%g\n',N);
for i=1:N
for j=1:N
fprintf(fid,'%g\n',mt(i,j));
end
end
quit
当我运行此命令时,matlab无法完全启动,并陷入此状态:
$ matlab -nodisplay -nojvm -nosplash -nodesktop -r "matrix(10,'test')"
< M A T L A B (R) >
Copyright 1984-2016 The MathWorks, Inc.
R2016a (9.0.0.341360) 64-bit (glnxa64)
February 11, 2016
奇怪的是,这不是一个小时前发生的。我没有以任何方式更改代码。有足够的系统内存。当我运行以下代码时:
matlab -nodisplay -nojvm -nosplash -nodesktop
它正确启动了matlab:
$ matlab -nodisplay -nojvm -nosplash -nodesktop
< M A T L A B (R) >
Copyright 1984-2016 The MathWorks, Inc.
R2016a (9.0.0.341360) 64-bit (glnxa64)
February 11, 2016
For online documentation, see http://www.mathworks.com/support
For product information, visit www.mathworks.com.
Academic License
>>
可能是什么问题?