When you need to get and set environment variables in MATLAB that are shared with the shell, start MATLAB directly from xterm or Terminal.
Alternatively, you can modify your shell configuration and initialization so that environment variables can be shared.
On UNIX platforms, the MATLAB function system, as well as dos, unix, and bang (!), are executed in a shell. The shell is chosen in this order:
* Environment variable MATLAB_SHELL
* Environment variable SHELL
* /bin/sh
If the chosen shell is tcsh then the system's .cshrc file is sourced for every MATLAB system (or related) function. In this case, all environment variables set in the .cshrc override MATLAB environment settings.
To prevent overriding MATLAB environment settings during system and related functions, you can do one of the following:
* Use setenv MATLAB_SHELL "${SHELL} -f" (the shell ignores the ~/.cshrc).
* Use setenv MATLAB_SHELL "/bin/sh" (choose the Bourne shell).
* Modify ~/.cshrc to skip setting environment variables if the shell is not interactive. Specifically, insert these statements in ~/.cshrc before changing the environment: if ($?USER == 0 || $?prompt == 0) exit
Best Answer