delete

Deletes graphics objects, or files by name.

Category: Graphics > Graphics Objects

Syntax

delete(h)

Removes the graphics objects with handles h, together with their children.

delete(filename)

Deletes the named file; wildcards such as *.tmp are allowed.

Description

After delete(h) the handle variable still exists but is no longer valid; test it with isvalid or ishandle. Deleting an axes or figure removes everything inside it. For a file, delete is silent when the file is missing, apart from a warning.

Input arguments

h
Handle or array of handles.
filename
Text with a file name or pattern.

Example

Remove a line

figure
ax = axes;
h = plot(1:3);
disp(numel(allchild(ax)))
delete(h)
disp(numel(allchild(ax)))
Output
     1
     0

See also

close ishandle allchild copyobj