You cannot do that the way you are trying. Each system() or unix() call opens a new shell, does the operation in that shell, and then destroys the shell. Environment variables set in a shell only affect that shell and any subshells, and never any shells "upward".
What you should do is, in MATLAB,
after which you can
This sets the the variable in the environment variables being held by the MATLAB process itself, and those variables then apply to any shells that MATLAB creates afterwards in the same proces, such as if you system() or unix()
Best Answer