文档

这是机器翻译

被某某人翻译微软
Mouse over text to see original. Click the button below to return to the English verison of the page.

光盘

更改当前文件夹

句法

CD(新手)
OldFolder = CD(NewFolder)
光盘

描述

光盘(新建文件夹将当前文件夹更改为新建文件夹

OldFolder = CD(NewFolder)将现有当前文件夹作为字符串返回到OldFolder,然后将当前文件夹更改为新建文件夹

光盘显示当前文件夹。

输入参数

新建文件夹

指定要更改当前文件夹的文件夹的字符串。有效值可以是以下任何一个:

  • 完整的或相对的路径。

  • ../,这表示从当前文件夹上升一个级别。

  • Multiple strings of../,这表明从当前文件夹上升多个级别。

  • 。/,这表示相对于当前文件夹的路径,尽管没有。/,,,,光盘假设该路径相对于当前文件夹。

输出参数

OldFolder

A string specifying the current folder that was in place when you issued the光盘命令。

定义

The current folder is a reference location that MATLAB®用于查找文件。这个文件夹有时称为current directory,,,,当前的工作文件夹, 或者目前的工作目录

例子

采用光盘with thematlabroot将当前文件夹更改为MATLAB的当前运行版本的示例目录:

CD(FullFile(Matlabroot,'/help/techdoc/matlab_env/示例')

在微软®Windows®平台,指定将当前文件夹从任何位置更改为MATLAB版本7.11(R2010B)的示例目录的完整路径,假设版本已安装在您的C:驾驶:

cd(“C: /程序文件/ MATLAB / R2010b /帮助/ techdoc / matlab_env/examples') % Change the current folder from % C:/Program Files/MATLAB/R2010b/help/techdoc/matlab_env/examples to % C:/Program Files/MATLAB/R2010b/help/techdoc: cd ../.. % Use a relative path to change the current folder from % C:/Program Files/MATLAB/R2010b/help/techdoc back to % C:/Program Files/MATLAB/R2010b/help/techdoc/matlab_env/examples: cd matlab_env/examples % Change the current folder from its current location to a new % location,but save its previous location. Later, change the % current folder to the previous location. % This returns % C:/Program Files/MATLAB/R2010b/help/techdoc/matlab_env/examples % to oldFolder, and then changes the current folder to % C:/Program Files: oldFolder = cd('C:/Program Files') % Display current folder: pwd % Change the current folder to the previous location: cd(oldFolder) pwd

在Unix上®平台,将当前文件夹更改为当前正在运行的MATLAB的示例目录,假设它安装在您的家庭位置:

CD('〜/help/techdoc/matlab_env/示例')

更多关于

全部收缩

尖端

  • 使用命令语法时(光盘newfolder),,,,if the新建文件夹字符串包含空格,将字符串包裹在单引号标记中。

  • On UNIX platforms, use the(tilde)字符代表用户主目录。

  • 如果您使用光盘在本地函数中,程序控制从函数返回后,文件夹更改持续存在。也就是说,文件夹更改的范围是全局。

也可以看看

||||

在R2006a之前引入

这个话题有帮助吗?