PRT Blog

MATLAB Pattern Recognition Open Free and Easy

Using prtPath

We recommend as part of installation that you edit (or create) your startup.m file to include a call to prtPath. This is adds the PRT to your MATLAB search path automatically each time you start MATLAB. There are alternatives to path management (such as the pathtool() or addpath() and savepath()) but we recommend using a startup.m file. Hopefully this post will explain one reason we recommend that.

One of the reasons that we like to use prtPath in a startup file is that prtPath does more than just add the PRT and all of it’s subfolders to your path.


prtPath and ] directories

prtPath is actually very basic. It calls the function prtRoot and uses the MATLAB function genpath() to get a list of all of the subdirectories in the prtFolder. It then eventually calls addpath() to add that list of directories to the MATLAB path (it does not save the path for future sessions of MATLAB).

Before prtPath() calls addpath() though, it selectively removes some directories from the subdirectory list.

First it removes any directory that starts with a “.”. This was added to prevent any hidden folders (like those from source control systems) from showing up in the MATLAB path.

More importantly though, it removes any folders from the list that start with a “]”. This is something special that we put in to add some extra functionality to the PRT.

Most of our users want to stick to code that is well tested and is known to behave nicely. But as we go about our jobs and use the PRT we need to add some new functionality. We typically add things like: new classifiers, new datatypes or new pre processing techniques.

Some of our users want access to this newest code so it gets added to the PRT in the “]alpha” and eventually the “]beta” folder. By default prtPath will not include these folders in the path. Instead you have to tell prtPath that you are willing to accept the responsibilities of the bleeding edge. You do this by giving prtPath a list of “]” folders that you want to include. (Or rather not exclude).

For example:

prtPath('alpha', 'beta');

will add both the “]alpha” and “]beta” folders (and their subfolders) to the path.

Currently in the PRT we have one other “]” folder, “]internal”. In the internal folder you will find some code on unit testing and documentation building. You probably wont be interested in much that’s in there so I probably wouldn’t clutter my path with it.

Why “]”?

We were searching for a character that is a valid path (folder) name character on all major operating systems and is at the same time a character that most people wouldn’t start a directory name with. MATLAB already uses “@” for (old style) class definitions and “+” for packages. We thought “]” fit all of these criteria.


We hope that cleared up a little of why we recommend prtPath over pathtool(), at least for the PRT. In general just call prtPath() by itself but if you want to see what might lie ahead for the PRT checkout the ]alpha and ]beta folders. In some future posts we will talk about some things in these folders that might be of interest to you. Maybe that will entice you to explore the ].