Home > programming > Why is my modified path not saved in MATLAB?

Why is my modified path not saved in MATLAB?


Subject:

Why is my modified path not saved in MATLAB?

Problem Description:

I add a path using the “Set Path” GUI, and then save it. When I exit MATLAB and restart it, the added paths are no longer on the search path.

 

Solution:

The MATLAB path information is saved in the file “pathdef.m”. When the “Save” button in the “Set Path” GUI is pressed, the location of the file pathdef.m is determined using the output of the function WHICH.

If there is a file called pathdef.m inside one of the directories that were just added to the top of the MATLAB search path, then this file is used to save the changes to the path instead of using the built-in file $MATLABROOT\toolbox\local\pathdef.m (where $MATLABROOT is your root MATLAB directory).

This can be verified by calling the following right after saving the path changes:
which pathdef -all

Normally, only one file should be found:
$MATLABROOT\toolbox\local\pathdef.m

If multiple files are found, then the path changes are saved to the file that appears topmost.

Always avoid using file names that collide with built-in MATLAB files. The newly added directories could also be moved to the bottom of the search path, this way the function WHICH will find $MATLABROOT\toolbox\local\pathdef.m first, and will save the path changes there.

Advertisements
Categories: programming
  1. No comments yet.
  1. No trackbacks yet.

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: