Persistent user paths to Matlab and Octave

Matlab .mltbx toolbox packaged toolbox format is proprietary to Matlab. Oftentimes we desire to distribute a Matlab package as a set of .m source files instead. To add a “toolbox” or “package” to Matlab and use functions from that toolbox requires using “addpath” or “import” Matlab syntax. This example makes those paths persistent in Matlab and Octave, using example toolbox directories ~/mypkg1 and ~/mypkg2.

Normally use addpath() instead of cd(). Do not put brackets or braces around the multiple paths.

Prepend a package to the Matlab path by editing the startup.m file from Matlab or Octave:

edit(fullfile(userpath,'startup.m'))

put in addpath() commands to the desired Matlab packages paths like:

addpath('~/mypkg1','~/mypkg2')

Restart Matlab/Octave and type

path

and the new toolbox directories will be at the top.