Matlab from command line (-nodisplay -nojvm) segmentation violation on exit, on Mac OS
13 ビュー (過去 30 日間)
古いコメントを表示
Certain programs crash when I try to exit them from the command line (or call them within Python). (The weird thing is I have not been able to determine what causes some programs to crash and some not to.) So e.g. here is a very simple Matlab program (bugtest.m) which does crash:
function bugtest(ifile, ofile)
data = csvread(ifile, 1, 0); % skip the first line
csvwrite(ofile, data);
end
Now, when I call it from the command line, and exit separately, it works fine:
bash> /Applications/MATLAB_R2018b.app/bin/matlab -nodisplay -nojvm -r "bugtest('z2.csv','z3.csv')"
< M A T L A B (R) >
Copyright 1984-2018 The MathWorks, Inc.
R2018b (9.5.0.944444) 64-bit (maci64)
August 28, 2018
For online documentation, see https://www.mathworks.com/support
For product information, visit www.mathworks.com.
>> exit
exit
But what I actually want it to do is to exit as well, i.e. include the exit on the command line, and it crashes (depending on the program, but the program bugtest.m always crashes):
bash> /Applications/MATLAB_R2018b.app/bin/matlab -nodisplay -nojvm -r "bugtest('z2.csv','z3.csv');exit"
< M A T L A B (R) >
Copyright 1984-2018 The MathWorks, Inc.
R2018b (9.5.0.944444) 64-bit (maci64)
August 28, 2018
For online documentation, see https://www.mathworks.com/support
For product information, visit www.mathworks.com.
--------------------------------------------------------------------------------
Segmentation violation detected at Thu Aug 22 15:55:40 2019 +0930
--------------------------------------------------------------------------------
How do I fix this?
3 件のコメント
Aakriti Suman
2020 年 3 月 26 日
Hi Peter,
Could you please send us the csv files that you are using in your MATLAB code? It will help us in investigating your query better.
回答 (1 件)
Aakriti Suman
2020 年 3 月 27 日
編集済み: Aakriti Suman
2020 年 3 月 27 日
I understand that you are not able to execute a user defined function and the 'exit' command one after the other at once through the command line.
I tried to execute a simple script as below.
function bugtest(a)
sum = a+2;
disp(sum)
end
Through the command line, I called the above function in two ways:
- >>bugtest(2)
>>exit
- >>bugtest(2);exit
In both the above ways, my MATLAB did not crash and the MATLAB window exited normally.
Since you are using python as a third party tool, there is a slight possibility that the usage of both the tools simulataneously is not being used correctly.
I also see that you are using R2019 version of MATLAB. 'csvread' function has compatibility issues with MATLAB R2019a and later versions.
You can use 'readmatrix' instead of 'csvread' function. I am attaching its documentation link for your reference.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Call Python from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!