delete, _delete

Delete the value of an identifier

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


delete x1, x2, …
_delete(x1, x2, …)


The statement delete x deletes the value of the identifier x.

For many computations, symbolic variables are needed. E.g., solving an equation for an unknown x requires an identifier x that does not have a value. If x has a value, the statement delete x deletes the value and x can be used as a symbolic variable.

The statement delete x1, x2, ... is equivalent to the function call _delete(x1, x2, ...). The values of all specified identifiers are deleted.

The statement delete x[j] deletes the entry j of a list, an array, an hfarray, or a table named x. Deletion of elements or entries reduces the size of lists and tables, respectively.

If x is an identifier carrying properties set via assume, then delete x detaches all properties from x, i.e., delete x has the same effect as unassume(x). Cf. Example 3.


Example 1

The identifiers x, y are assigned values. After deletion, the identifiers have no values any longer:

x := 42: y := 7: delete x: x, y

delete y: x, y

More than one identifier can be deleted by one call:

a := b := c := 42: a, b, c

delete a, b, c: a, b, c

Example 2

delete can also be used to delete specific elements of lists, arrays, hfarrays, and tables:

L := [7, 13, 42]

delete L[2]: L

A := array(1..3, [7, 13, 42])

delete A[2]: A, A[2]

T := table(1 = 7, 2 = 13, 3 = 42)

delete T[2]: T

Note that delete does not evaluate the objects that are to be deleted. In the following, an element of the list U is deleted. The original value of U (the list L) is not changed:

U := L: delete U[1]: U, L

Finally, all assigned values are deleted:

delete U, L, A, T: U, L, A, T

Example 3

delete can also be used to delete properties of identifiers set via assume. With the assumption “x > 1”, the expression ln(x) has the property “ln(x) > 0”, i.e., its sign is 1:

assume(x > 1): sign(ln(x))

Without a property of x, the function sign cannot determine the sign of ln(x):

delete x: sign(ln(x))


x1, x2, …

identifiers or indexed identifiers

Return Values

Void object of type DOM_NULL.

See Also

MuPAD Functions