cd - Change working directory

Graphical Interface

As an alternative to the cd function, use the current directory field

in the MATLAB® desktop toolbar.

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 pathname for directory. On UNIX® 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

On UNIX platforms,

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

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

On Windows® platforms,

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

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

cd ..

changes the current working directory to control, and typing

cd ..

again, changes the current working directory to toolbox.

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

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

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

See Also

dir, fileparts, mfilename, path, pwd, what

  


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