linux – 指定MATLAB故障转储文件的输出目录

我在
Linux上运行MATLAB,在我的主目录(/ home / $USER)中存储空间有限.当MATLAB崩溃时,它会将故障转储文件(matlab_crash_dump.XXXX)放在我的主目录中.我想更改放置这些文件的目录.做这个的最好方式是什么? 最佳答案 您需要指定MATLAB_LOG_DIR环境变量. MATLAB将使用它来存储所有故障转储.

related MATLAB Central discussion

If you have set the environment variable $MATLAB_LOG_DIR, that’s where
we’ll write the crash dump file. Otherwise, look in $HOME on UNIX, or
in $TEMP, $TMP, $WINDIR, and finally C:\ (in that order) on Windows.
The file will be named “matlab_crash_dump.$pid” where $pid is the
process ID of MATLAB.

您可以在.bashrc文件中执行此操作

export MATLAB_LOG_DIR=/custom/dir

或者在运行任何命令之前(或在你的matlabrc file内)在MATLAB中

setenv('MATLAB_LOG_DIR', '/custom/dir')

如果您需要对此进行测试,则以下简单的mex文件将导致崩溃,从而导致崩溃转储文件.

#include "mex.h"

void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
{
    /* Access beyond the length of prhs */
    size_t x = mxGetM(prhs[6]);
}
点赞