| MATLAB® | ![]() |
As an alternative to the delete function, you can delete files using the Current Directory browser.
delete filename
delete(h)
delete(handle_array)
delete('filename')
delete filename deletes the named file from the disk. The filename can include an absolute path or a path relative to the current directory. The filename can also include wildcards, (*).
delete(h) deletes the graphics object with handle h. The function deletes the object without requesting verification, even if the object is a window.
delete(handle_array) is a method of the handle class. It removes from memory the handle objects referenced by handle_array.
Once deleted, any references to the objects in handle_array become invalid. You can remove the handle variables using the clear function.
delete('filename') is the function form of delete. Use this form when the file name is stored in a string.
Note The MATLAB software does not ask for confirmation when you use delete. To avoid accidentally losing files or graphics objects, make sure you have accurately specified the items you want deleted, or use the recycle preference and the recycle function. |
The action that the delete function takes on deleted files depends upon the setting of the recycle state in MATLAB. If you set the recycle state to on, MATLAB moves deleted files to your recycle bin or temporary directory. With the recycle state set to off (the default), deleted files are permanently removed from the system.
To set the recycle state for all MATLAB sessions, use preferences—select File > Preferences > General. To enable or disable recycling, use Move files to the Recycle Bin or Delete files permanently. See Setting General Preferences for the MATLAB Application in the Desktop Tools and Development Environment documentation for more information.
The delete function deletes files and handles to graphics objects only. Use the rmdir function to delete directories.
To delete all files with a .mat extension in the ../mytests/ directory, type
delete('../mytests/*.mat')To delete a directory, use rmdir rather than delete:
rmdir mydirectory
recycle, dir, edit, fileparts, mkdir, rmdir, type
Managing Files and Working with the Current Directory
![]() | delaunayn | delete (COM) | ![]() |
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |