Skip to content

delete

miscellaneous · scripts/miscellaneous/delete.m

: delete (file)
: delete (file1, file2, …)
: delete (h)

Delete files, graphics objects, or handle-class objects.

Each file is a name or a wildcard pattern (‘*’, ‘?’ or ‘[…]’). Only files are removed: folders are never touched, and patterns only match the files they name. Names that match nothing are ignored.

When the argument is a numeric array of graphics handles h, the graphics objects are deleted.

When the argument is a classdef handle object, method dispatch uses the object’s delete method (and the built-in handle.delete lifecycle) rather than this file function – matching MATLAB R2026a. After a successful handle delete, isvalid is false and property access raises MATLAB:class:InvalidHandle.