How do I set add or change environment variables?
293 views (last 30 days)
MathWorks Support Team on 22 Dec 2021
Edited: MathWorks Support Team on 22 Dec 2021
Below are instructions for setting environment variables for various platforms.
== Windows ==
Open the Environment Variables dialog by following these two steps:
1) From Start -> Run
, execute the following CPL command "sysdm.cpl", this will open the System Properties dialog
2) Click on the Advanced tab, click on the "Environment Variables..." button, this will open the Environment Variables dialog
You can now create/edit both "System variables" as well as "User variables"; the system variables will be shared for all users, while user variables affect only your account/profile.
== Mac/Linux OS ==
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:
For a tcsh or csh shell, use the following syntax:
setenv <name> <value>
setenv JAVA_HOME /usr/local/
For a bash shell use the following syntax:
Note that the environment variable has only effect on that particular instance of that shell. If you try to open a new shell or start a program outside your original shell the environment variable you created will not have an effect.