Development Environment    

Creating, Renaming, Copying, and Removing Directories and Files

If you have write permission, you can create, copy, remove, and rename MATLAB related files and directories for the directory shown in the Current Directory browser. If you do not have write permission, you can still copy files and directories to another directory, or you can use equivalent functions, such as movefile.

Creating New Files

To create a new file in the current directory:

  1. Select New from the context menu or File menu and then select the type of file to create.
  1. An icon for that file type, for example, an M-file icon , with the default name Untitled appears at the end of the list of files shown in the Current Directory browser.

  1. Type over Untitled with the name you want to give to the new file.
  2. Press the Enter or Return key.
  1. The file is added.

  1. To enter the contents of the new M-file, open the file--see Opening, Running, and Viewing the Content of Files. If you created the file using the context menu, the new file opens in the Editor with a template for writing an M-file function.

Function Alternative.   Use the edit function to create a new M-file.

Creating New Directories

To create a new directory in the current directory:

  1. Click the new folder button in the Current Directory browser toolbar, or select New -> Folder from context menu.
  1. An icon, with the default name NewFolder appears at the end of the list of files shown in the Current Directory browser.

  1. Type over NewFolder with the name you want to give to the new directory.
  2. Press the Enter or Return key.
  1. The directory is added.

Function Alternative.   To create a directory, use the mkdir function. For example,

creates the directory newdir within the current directory.

Renaming Files and Directories

To rename a file or directory, select the item, right-click, and select Rename from the context menu. Type over the existing name with the new name for the file or directory, and press the Enter or Return key. The file or directory is renamed.

Function Alternative.   You can use movefile to rename a file or directory. For example,

renames myfile.m to projectresults.m.

Cutting or Deleting Files and Directories

To cut or delete files and directories:

  1. Select the files and directories to remove. Use Shift+click or Ctrl+click to select multiple items.
  2. Right-click and select Cut or Delete from the context menu.
  1. The files and directories are removed.

On Windows platforms, files you delete from the Current Directory browser go to the Recycle bin. If you do not want the selected items to go to the Recycle bin, press Shift+Delete. A confirmation dialog box displays before the items are deleted.

Function Alternative.   To delete a file, use the delete function. For example,

deletes the file testfun.m.

To delete a directory and optionally its contents, use rmdir. For example,

removes the directory myfiles from the current directory.

Copying and Pasting Files

Using the Current Directory browser, you can copy and paste files, but not directories. To copy and paste files:

  1. Select the files. Use Shift+click or Ctrl+click to select multiple items.
  2. Right-click and select Copy from the context menu.
  3. Move to the directory where you want to paste the files you just copied or cut.
  4. Paste the files by right-clicking and selecting Paste from the context menu.

Function Alternative.   Use movefile or copyfile to cut and paste or to copy and paste files or directories. For example, to make a copy of the file myfun.m in the current directory, assigning it the name myfun2.m, type


  Viewing and Making Changes to Directories Opening, Running, and Viewing the Content of Files