Child pages
  • Setting Paths in Matlab
Skip to end of metadata
Go to start of metadata

Erick Pomplun updated March 13 at 5:35 PM


Helpful Links - Adding Paths in Matlab

Set paths button




At the top right section of the Matlab window there is a "Set Path" button which will allow you to add folders to your paths. In the next menu by clicking on the add folders button you will be able to select folders you would like to add to your path. Make sure to hit save after you've chosen the folders you need to add.



Using the Savepath command to set your path

Alternatively you can use the savepath command within MATLAB to save your current path to a file called pathdef.m which is read upon startup. savepath saves the current MATLAB search path to an existing pathdef.m file in the current folder. If there is no pathdef.m file in the current folder, then savepath saves the search path to the first pathdef.m file on the current path. If there is no such file on the current path, then savepath saves the search path to the pathdef.m file. The syntax for this command is the following:

savepath /Users/your username here/Documents/MATLAB/pathdef.m

Using the Genpath command to set your path

You can use the genpath command in tandem with the addpath within MATLAB to not only generate a path to a folder but also include all of the folder's subfolders as well. Below is an example on how to add a folder and all of its subfolders

genpath ('Foldername')

Please note that this does no save this path the way that the savepath command does. By using the addpath command you can add the path generated to your MATLAB search path using the following syntax

  1. p= genpath ('Foldername') p= genpath ('Foldername')
  2. addpath (p) addpath (p)


  • No labels