Add a path to run external programs in MATLAB

I wanted to add a path to MATLAB to allow me to run external programs while in MATLAB. Copied straight from the MATLAB user guide:

Modify the UNIX System Path that MATLAB Uses. Add the folders to the system path from the shell. The exact steps depend on your shell. This is an example using sh:

  1. At the system command prompt, type
    export PATH="$PATH:<myfolder>"

    where <myfolder> is the folder that contains the program you want to run.

  2. Start MATLAB.
  3. In the MATLAB Command Window, type
    !echo $PATH

The folder containing the file is added to the system path that MATLAB uses. This change applies only to the current session of the terminal window.

Automatically Modify the System Path When MATLAB Starts. If you want to add a folder to the PATH environment variable each time you start MATLAB, perform these steps:

  1. In a text editor, open the file MATLAB/bin/matlab. This file is used to start MATLAB.
  2. Add this line to the beginning of the matlab file
    export PATH="$PATH:<myfolder>"

    where <myfolder> is the folder you want to add to the path.

    If you run a tsch shell instead of a bash shell, use setenv instead of export.

  3. Save the file.

The matlab file will modify the PATH environment variable, and then start MATLAB.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.