Documentation

unalias

Deletes an alias

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.

Syntax

unalias(x1, x2, …, <Global>)
unalias(<Global>)

Description

unalias(x) deletes the abbreviation or macro x. To delete a macro defined by alias(f(y1, y2, ...) = object), use unalias(f). If no alias for x or f is defined, then the call is ignored.

unalias() deletes all abbreviations and macros.

Multiple alias definitions may be deleted by a single call of unalias. The call unalias() deletes all currently defined aliases.

unalias does not evaluate its arguments.

Note

If you use an identifier as an abbreviation, you cannot use that same identifier directly. You must use unalias before you can define another abbreviation or macro for the same identifier. See Example 2.

Assigning a value to one of the identifiers on the left side of an alias definition, or deleting its value does not affect the alias substitution, neither in the input nor in the output.

Environment Interactions

alias with at least one argument and unalias change the parser configuration in the way described in the “Details” section.

Examples

Example 1

Define d as a shortcut for diff:

delete f, g, x, y: alias(d = diff):
d(sin(x), x) = diff(sin(x), x);
d(f(x, y), x) = diff(f(x, y), x)  Define a macro Dx(f) for diff(f(x), x). Note that hold does not prevent alias substitution:

alias(Dx(f) = diff(f(x), x)):
Dx(sin); Dx(f + g); hold(Dx(f + g))   After the call unalias(d, Dx), no alias substitutions happen any longer:

unalias(d, Dx):
d(sin(x), x), diff(sin(x), x), d(f(x, y), x), diff(f(x, y), x);
Dx(sin), Dx(f + g)  Example 2

Define a to be an abbreviation for b. Then the next alias definition is really an alias definition for b:

delete a, b:
alias(a = b): alias(a = 2): type(a), type(b); unalias(b): Use unalias first before defining another alias for the identifier a:

unalias(a): alias(a = 2): type(a), type(b); unalias(a): A macro definition, however, can be added if the newly defined macro has a different number of arguments. unalias(a) removes all macros defined for a:

alias(a(x)=sin(x^2)): a(y); alias(a(x)=cos(x^2)): Error: Invalid operand. [_power]
Evaluating: alias
alias(a(x, y) = sin(x + y)):
a(u, v);
alias():
unalias(a): a(x)   = sin(x^2)
a(x, y) = sin(x + y)

Example 3

When called without arguments, alias just displays all currently used aliases:

alias(a = 5, F(x) = sin(x^2)):
alias();
unalias(F, a):
F(x) = sin(x^2)
a   = 5

Parameters

 x1, x2,… Identifiers or symbolic expressions of the form f(y1, y2,…), with identifiers f, y1, y2,... object1, object2,… Any MuPAD® objects

Options

 Global Definition of an alias in the global parser context. When an alias is defined in a library or package source file, it will be deleted automatically after reading the file. With option Global the alias is not active in the file being read, but in the interactive level after reading of the file is finished.

Return Values

Both alias and unalias return the void object of type DOM_NULL.

Algorithms

The aliases are stored in the parser configuration table displayed by _parser_config(). Note that by default, alias back-substitution happens for the right sides of the equations in this table, but not for the indices. Use print(_parser_config()) to display this table without alias back-substitution.

Aliases are not used while a file is read using read or fread with the option Plain. Conversely, if an alias is defined in a file which is read with option the Plain, the alias is only used until the file has been read completely.