cd - Change working directory

GUI Alternatives

As an alternative to the cd function, you can change the current directory using the current directory field on the desktop toolbar or using the Current Directory browser.

Syntax

cd
w = cd
cd('directory')
cd('..')
cd directory

Description

cd displays the current working directory.

w = cd assigns the current working directory to w.

cd('directory') sets the current working directory to directory. Use the full path for directory. On UNIX[1] platforms, the character ~ is interpreted as the user's root directory.

cd('..') changes the current working directory to the directory above it.

cd directory or cd .. is the unquoted form of the syntax.

Examples

UNIX Platforms

On UNIX platforms, to change the current working directory to ctrldemos for the Control System Toolbox™ software, run

cd('/usr/local/matlab/toolbox/control/ctrldemos')

Windows Platforms

On Microsoft Windows platforms, to change the current working directory to ctrldemos for the Control System Toolbox software, run

cd('c:/matlab/toolbox/control/ctrldemos')

Then change the current working directory to control by running

cd ..

Then change the current working directory to toolbox by running

cd ..

Change to matlabroot Directory

On any platform, use cd with the matlabroot function to change to a directory relative to the directory in which the MATLAB executable is installed. For example,

cd([matlabroot '/toolbox/control/ctrldemos'])

changes the current working directory to ctrldemos for the Control System Toolbox software.

See Also

dir, fileparts, mfilename, path, pwd, what

Managing Files and Working with the Current Directory


[1] UNIX is a registered trademark of The Open Group in the United States and other countries.

  


 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS