How to Delete a File With MATLAB

Written by michael carroll
  • Share
  • Tweet
  • Share
  • Email

MATLAB uses files to store numeric and graphical results, and MATLAB functions and code may be contained in files as well. Delete files in the default file path -- the "MATLAB" folder in your user "Documents" directory in a typical Windows installation -- or elsewhere using the "delete" command, or with the file browser in the MATLAB desktop.

Skill level:


  1. 1

    Launch MATLAB and choose a file to delete. To quickly create a new file to work with, type the following command into the Command Window:

    save testfile.m

  2. 2

    Use the "delete" command to delete a file programmatically:

    delete testfile.m

    Specify the whole path of the file (e.g.,"C:...") if it isn't in the MATLAB default path. Delete multiple files using the following syntax:


  3. 3

    Right-click a file in the "Current Directory" browser and choose "Delete" from the drop-down menu to delete the file using the MATLAB interface.

Tips and warnings

  • Use the asterisk as a wild-card character to delete many files at once. For example, to delete several files whose names start with "testfile," use the following command:
  • delete testfile*

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.