Adding persistent user-defined paths to Matlab and Octave

Oftentimes we add a “toolbox” to Matlab that someone has created and we want to use functions from that toolbox without adding the path over and over in functions. Here’s how to make those paths persistent in Matlab and Octave.


  1. Add to file ~/Documents/MATLAB/startup.m


    Note that you don’t put brackets or braces around the multiple paths. 

  2. restart Matlab and type


and you should see your new toolbox directories at the top.


Octave 4.2 and newer load and parse ~/startup.m like Matlab does.

If Matlab doesn’t autoload startup.m

You may have an older version of Matlab that doesn’t automatically load from ~/Documents/MATLAB/startup.m. Fix this with the one-time Terminal command

echo "export MATLAB_USE_USERWORK=1" >> ~/.bashrc