转载请注明出处
ubuntu 20.04系统,安装matlab r2020a后,在 /usr/share/applications 中建立desktop文件,无法通过desktop方式打开matlab,显示如下启动窗口后就闪退。
不妨假设:
matlab可以执行文件位置 /usr/local/Matlab/R2020a/bin/matlab
matlab license文件位置 /usr/local/Matlab/R2020a/licenses/license.lic
可以尝试这样解决:
先确保matlab可执行文件可以不用root权限执行
sudo chmod 777 /usr/local/Matlab/R2020a/bin/matlab
建立shell脚本 run_matlab
:
nohup /usr/local/Matlab/R2020a/bin/matlab -softwareopengl -desktop -c /usr/local/Matlab/R2020a/licenses/license.lic >/dev/null 2>&1 &
然后 sudo chmod 777 /usr/local/Matlab/R2020a/bin/run_matlab
将desktop文件中的可执行文件由matlab替换为run_matlab。
完成。
如果还是不行就只有用命令行的方式了。
将前文run_matlab所在目录( /usr/local/Matlab/R2020a/bin/
)加入PATH
gedit ~/.bashrc
在末尾加入新的一行
export PATH=/usr/local/Matlab/R2020a/bin:$PATH
立即生效
source ~/.bashrc
这样只要在任意终端输入run_matlab即可运行matlab了,而且关闭终端也不影响已打开的matlab窗口。