Changing the working directory: The cd command

The command cd reveals your currect working directory. It is important that all Matlab files you use are in that directory. If you change a file, you must save it in your working directory or in a directory accessed by the Matlab path before you execute it. To change your working directory, use the command cd "directory-name". E.g.: cd C:\M2214\Matlab

Matlab has a path that searches a given list of directories in addition to your working directory for files to execute. To see this path, execute the command path. You can add a directory to the path by executing the command path(path,'directoryname')as follows:

  • Unix: path(path,'/home/myfriend/goodstuff')
  • PC: path(path,'C:\TOOLS\GOODSTUFF')
  • Mac: path(path,'HardDisk:Tools:GoodStuff:')