How do I set add or change environment variables?
348 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 11 de Jun. de 2015
Editada: MathWorks Support Team
el 18 de Ag. de 2023
In the process of troubleshooting MATLAB, I have been asked to change the environment variables on my machine. How can I set or change the environment variables?
Respuesta aceptada
MathWorks Support Team
el 17 de Ag. de 2023
Editada: MathWorks Support Team
el 18 de Ag. de 2023
Below are instructions for setting environment variables on different Operating Systems.
Windows
Open the Environment Variables dialog by following these two steps:
1) In Windows Start Menu, type "env" then select "Edit the system environment variables"
2) Click the "Environment Variables..." button
You can create System Variables or User Variables using the "New..." button.
You can edit existing variables by selecting one from the list then click the "Edit..." button.
The system variables will be shared for all users, while user variables only affect your account/profile.
Linux/macOS
There are multiple ways to set environment variables depending on the type of shell you are using. To determine the your shell type, use the "echo" command to see the value of the "SHELL" environment variable:
echo $SHELL
For a tcsh or csh shell, use the following syntax:
setenv <name> <value>
for example:
setenv JAVA_HOME /usr/local/
For a bash shell, use the following syntax:
export <name>=<value>
for example:
export JAVA_HOME=/usr/local/
Note that setting an environment variable using these methods on Linux or macOS will only affect the current Terminal session. If you try to open a new shell or start a program outside your original shell the environment variable will not apply.
1 comentario
Walter Roberson
el 15 de En. de 2023
The Windows sysdm.cpi that is discussed above makes permanent changes to the system.
For MacOS you should change a launchd plist https://apple.stackexchange.com/questions/289060/setting-variables-in-environment-plist and see https://stackoverflow.com/questions/135688/setting-environment-variables-on-os-x but be careful about which version the remarks there refer to (further down the page some people are specific about what is needed for which version.)
Más respuestas (0)
Ver también
Categorías
Más información sobre Environment and Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!