| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
cd(newFolder)
oldFolder = cd(newFolder)
cd newFolder
cd(newFolder) changes the current folder to the string newFolder.
oldFolder = cd(newFolder) returns the existing current folder as a string to oldFolder, and then changes the current folder to newFolder.
cd newFolder is the command syntax.
Valid values for newFolder follow. newFolder can be a full path or a relative path. Use ../ to move up one level from the current folder. Repeat ../ to move up multiple levels. newFolder can be ./ to indicate a path relative to the current folder, although without the ./, cd assumes that the path is relative to the current folder. For the command syntax, when newFolder contains spaces, enclose it inside single quotation marks. On UNIX platforms, use ~ (tilde) to represent the user home directory. With newFolder omitted, cd displays the current folder.
The current folder is a reference location that MATLAB uses to find files See The Current Folder in MATLAB.
Specify the full path to change the current folder from any location to ctrldemos, for the Control System Toolbox™ software:
cd('c:/matlab/toolbox/control/ctrldemos')Move up to change the current folder from c:/matlab/toolbox/control/ctrldemos to c:/matlab/toolbox:
cd ../..
Use a relative path to change the current folder from c:/matlab/toolbox to c:/matlab/toolbox/control/ctrldemos:
cd control/ctrldemos
On a UNIX platform, change the current folder to ctrldemos, for the Control System Toolbox software. MATLAB is installed in the user home location:
cd('~/matlab/toolbox/control/ctrldemos')Use the matlabroot function to change the current folder to ctrldemos for the Control System Toolbox software :
cd(fullfile(matlabroot, '/toolbox/control/ctrldemos'))
Change the current folder fromc:/matlab/toolbox/control/ctrldemos to c:/my_files, while saving its previous location. Later, change the current folder to the previous location:
oldFolder = cd('c:my_files') % Changes current folder to my_files
cd(oldFolder) % Changes current folder to c:/matlab/toolbox/control/ctrldemosUse the Current Folder field in the MATLAB desktop toolbar.
Use the address bar in the Current Folder browser.
dir | fileparts | path | pwd | what
![]() | caxis | convexHull (DelaunayTri) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |