This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

save, _save

Save the state of an identifier

MuPAD® notebooks are not recommended. 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.


save x1, x2, …
_save(x1, x2, …)


In a procedure, the statement "save x;" saves the state of the global identifier x.

The save statement saves the states of identifiers—i.e., their values and properties — during the execution of procedures. The original state of the identifiers is restored when procedure execution is finished. This holds even when an error occurs.

The save statement is to be used only inside the body of a procedure. It cannot be called on the interactive level.

The arguments of the save statement are evaluated as usual. In the statement ‘save x;', the symbol x must evaluate to an identifier y, say. It is the state of the identifier y that is saved.

The save statement is very similar to the save declaration for procedures. The main difference to the declaration is that, in order to make the declaration, one has to know the names of the identifiers to be saved in advance. The save statement allows to save identifiers which are known only at runtime.

The save statement is usually used in order to temporarily change the properties of an identifier, for example by calling the function assume. Eventually, the original properties of the identifiers are restored even if an error occurs.

The statement ‘save x1, x2, ...;' is equivalent to the function call _save(x1, x2, ...).


Example 1

First, we define a property for the identifier y:

assume(y < 0)

The properties of the identifier stored in x are changed temporarily during the execution of the following procedure p:

p := proc(x : DOM_IDENT)
    save x;
    assume(x > 0);
    is(x > 0)

From the procedure's result, we see that the properties of y were changed during the execution of p:


However, the original properties were restored after exiting p. The identifier y has its original properties:

is(y > 0), is(y < 0)

The restoration of the original properties is guaranteed even if some error occurs inside the procedure. The following procedure q raises an error after changing the identifier given by x:

q := proc(x : DOM_IDENT)
    save x;
    assume(x > 0);
    error("some error")
Error: some error [q]

Nevertheless, the original assumptions about y are restored:

is(y > 0), is(y < 0)

unassume(y): delete p, q:


x1, x2, …

Symbols evaluating to identifiers

Return Values

Void object of type DOM_NULL.

See Also

MuPAD Functions

Was this topic helpful?