This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

delete

Delete files or objects

Syntax

delete filename
delete filename1 ... filenameN
delete(obj)

Description

example

delete filename deletes filename from disk, without requesting verification. To change whether the specified file is permanently deleted or sent to the recycle bin, change the Deleting files preference. To do so, go to the Home tab and in the Environment section, click Preferences. Select MATLAB > General. Then, choose from one of the two options in the Deleting files section. By default, the Delete permanently option is selected.

Note

On Mac platforms, the Deleting files preference is not applied to files deleted from network drives. All files are deleted permanently.

delete filename1 ... filenameN deletes the specified files from disk.

example

delete(obj) deletes the specified object. If obj is an array, then delete deletes all objects in the array. obj remains in the workspace, but is no longer valid.

Examples

collapse all

Delete all files in the current folder with a .mat extension.

delete *.mat

Delete a graphics object and a graphics object array.

Create a bar chart and plot five lines. Then delete the bar chart.

b = bar(1:5);
hold on
P = plot(magic(5));
delete(b)

The Bar object variable b remains in the workspace, but no longer refers to an object.

display(b)
b = 

  handle to deleted Bar

Delete all the Line objects created by plot.

delete(P)

Input Arguments

collapse all

File name to delete, specified as a character vector or string scalar. filename can be an absolute or relative path and can include wildcards (*).

Data Types: char | string

Object to delete, specified as a single object or an array of objects.

Introduced before R2006a