Change current folder - MATLAB cd (2024)

Change current folder

collapse all in page

Syntax

cd

cd newFolder

oldFolder = cd(newFolder)

Description

example

cd displays the current folder.

example

cd newFolder changes the current folder to newFolder. Folder changes are global. Therefore, if you use cd within a function, the folder change persists after MATLAB® finishes executing the function.

example

oldFolder = cd(newFolder) returns the existing current folder to oldFolder, and then it changes the current folder to newFolder.

Examples

collapse all

Change Current Folder Using Full and Relative Paths

Open Script

Change the current folder to the featured examples folder for MATLAB R2017a, assuming that version is installed on your C: drive.

cd 'C:\Program Files\MATLAB\R2017a\examples\matlab_featured'

Using the full path, change the current folder from C:\Program Files\MATLAB\R2017a\examples\matlab_featured to C:\Program Files\MATLAB\R2017a.

cd ..\..

Use a relative path to change the current folder from C:\Program Files\MATLAB\R2017a back to C:\Program Files\MATLAB\R2017a\examples\matlab_featured.

cd examples\matlab_featured

Change, and then Restore Current Folder

Open Script

Change the current folder to the featured examples folder for MATLAB R2017a, assuming that version is installed on your C: drive. Then restore the current folder to its original location.

Change the current folder to the featured examples folder for MATLAB R2017a.

cd 'C:\Program Files\MATLAB\R2017a\examples\matlab_featured'

Change the current folder to C:\Program Files, saving the folder path before changing it.

oldFolder = cd('C:\Program Files')
oldFolder = 'C:\Program Files\MATLAB\R2017a\examples\matlab_featured'

Use the cd command to display the new current folder.

cd
C:\Program Files

Change the current folder back to the original folder, using the stored path. Use the cd command to display the new current folder.

cd(oldFolder)cd
C:\Program Files\MATLAB\R2017a\examples\matlab_featured

Change Current Folder to User Home Folder on UNIX®

Open Script

Change the current folder to the featured examples folder for MATLAB R2016b, assuming that version is installed in your user home folder on a UNIX platform.

cd ~/MATLAB/R2016b/examples/matlab_featured

Input Arguments

collapse all

newFolderNew folder path
character vector | string scalar

New folder path to which you want to change the current folder, specified as a character vector or string scalar. If newFolder is a string, enclose it in parentheses. For example, cd("FolderName").

Valid values include a full or relative path or one of these values.

../One level up from the current folder.
Multiples of ../Multiple levels up from the current folder.
./A path relative to the current folder. cd assumes that the path is relative to the current folder even if the ./ is not present.

If newFolder contains spaces, enclose it in single quotation marks. For example, cd 'Folder Name'.

On UNIX® systems, you can use the ~ (tilde) character to represent the user home folder. For example, ~/ or ~username/.

MATLAB resolves folder path names containing '.', '..', and symbolic links to their target location before changing the current folder. For example, if you specify c:\matlab\..\work, MATLAB resolves the path name to c:\work before changing the current folder.

Output Arguments

collapse all

oldFolder — Previous current folder
character vector

Previous current folder that was in place before you issued the cd command, returned as a character vector.

More About

collapse all

Current Folder

The current folder is a reference locationthat MATLAB uses to find files. This folder is sometimes referredto as the current directory, currentworking folder, or present working directory.

Extended Capabilities

Version History

Introduced before R2006a

expand all

On Windows machines, leading whitespace characters in the input path are no longer trimmed. Input paths containing leading whitespace characters cause an error to be thrown instead.

See Also

dir | pwd | what

Topics

  • Specify File Names
  • Files and Folders That MATLAB Accesses

MATLAB Command

You clicked a link that corresponds to this MATLAB command:

 

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Change current folder - MATLAB cd (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Change current folder - MATLAB cd (2024)
Top Articles
▷ 30 alternatyw TamilMV do oglądania filmów HD online ✅
Discovering The World Of Flixtor Free Movies
Barstool Sports Gif
Netr Aerial Viewer
Draconic Treatise On Mining
About Goodwill – Goodwill NY/NJ
Missing 2023 Showtimes Near Lucas Cinemas Albertville
Knaben Pirate Download
Keurig Refillable Pods Walmart
Builders Best Do It Center
Elizabethtown Mesothelioma Legal Question
Https://Store-Kronos.kohls.com/Wfc
Byte Delta Dental
Truck Trader Pennsylvania
Razor Edge Gotti Pitbull Price
How To Cancel Goodnotes Subscription
Ms Rabbit 305
Noaa Ilx
Wsop Hunters Club
Hewn New Bedford
How your diet could help combat climate change in 2019 | CNN
Amortization Calculator
All Breed Database
Scheuren maar: Ford Sierra Cosworth naar de veiling
Construction Management Jumpstart 3Rd Edition Pdf Free Download
University Of Michigan Paging System
Restaurants In Shelby Montana
2015 Kia Soul Serpentine Belt Diagram
Afni Collections
Nearest Ups Ground Drop Off
Hrconnect Kp Login
Ncal Kaiser Online Pay
Skepticalpickle Leak
Shoe Station Store Locator
Pay Stub Portal
Craigslist Texas Killeen
1475 Akron Way Forney Tx 75126
Craigslist Free Puppy
Edict Of Force Poe
In Polen und Tschechien droht Hochwasser - Brandenburg beobachtet Lage
About My Father Showtimes Near Amc Rockford 16
Pa Legion Baseball
Az Unblocked Games: Complete with ease | airSlate SignNow
Centimeters to Feet conversion: cm to ft calculator
Youravon Com Mi Cuenta
Headlining Hip Hopper Crossword Clue
Lebron James Name Soundalikes
Dayton Overdrive
Craiglist.nj
Psalm 46 New International Version
Turning Obsidian into My Perfect Writing App – The Sweet Setup
Lorcin 380 10 Round Clip
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 6349

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.