Matlab question: save path

I work with Matlab R2011a. I want to set the path to c: \ matlab (let's say). But it seems that the path setting is not saved, and I need to reset the path every time I start Matlab. Please advise.

+4
source share
3 answers

If you want to start Matlab on a specific path and automatically add this path to your search path, you will change the userpath setting:

 userpath('C:\matlab') 

If you want to start Matlab in a specific path without specifying the path to the search path, you have two options:

1) Create a startup.m file in the folder C:\Program Files\MATLAB\R2011a\toolbox\local and write in the file cd('C:\matlab') . Thus, whenever Matlab starts, it changes the path (you can also add other commands that should be executed at startup).

2) Right-click the Matlab icon, which you usually use to start the program, and in the properties write C:\matlab in the Start in line. Thus, whenever you start Matlab from a shortcut (but not otherwise), Matlab will change the path.

+3
source

Make sure you have access to all Matlab files. I had the same problem, but when I completely controlled the C: \ Program Files \ MATLAB \ R2012b folder (and all its subfiles and folders), I no longer had this problem.

To do this, right-click on the R2012b folder (or any other version) and open the properties.

On the Security tab, find your username in the list. If not, click "Change ..." and "Add ..." your name. Then click the full control in the allow column. For this, you may need an administrator password.

Click "ok", "ok" (this may take a couple of minutes). Set the path again, close Matlab, run it again and check if all setpath settings are all there.

+1
source

To add to Jonas's answer (because changing the user path didn’t work for me):

You can also use the start.m method "If you want to start Matlab in a specific path, and this path will be automatically added to your search path." For Linux:

start.m

 cd /path/to/my/folder % sets current working directory addpath(genpath('/path/to/my/folder')) % adds directory (and its subfolders) to the path list 

or for a window, I assume it will look like this:

start.m

 cd c:\path\to\my\folder % sets current working directory addpath(genpath('c:\path\to\my\folder')) % adds directory (and its subfolders) to the path list 
0
source

All Articles