This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Prevent Evaluation

When you perform interactive computations in MuPAD®, the system tries to evaluate all expressions before returning them. For example, if the system can compute an integral, it returns the evaluated result. In most cases, the result is also simplified:

int(x^2*sin(x), x)

The hold command enables you to prevent the evaluation of a MuPAD object. For example, hold lets you display the integral in its symbolic form:

hold(int)(x^2*sin(x), x) = int(x^2*sin(x), x)

Also, you can prevent evaluation of an object by using the level function with the second argument 0. When you use level to prevent evaluation of identifiers, the results are equivalent to the results obtained with the hold function:

level(int(x^2*sin(x), x), 0)

The level function only prevents evaluation of identifiers. If you create a function without a name, for example , level does not prevent evaluation of that function:

level((x -> sin(x))(PI), 0)

In this case, use the hold function to prevent evaluation. For example, hold successfully prevents evaluation of the function at the point x = π:

hold((x -> sin(x))(PI))

Both hold and level functions prevent the evaluation of an object only in the particular computation in which you explicitly use them. These functions do not prevent further evaluations. For example, if you assign an expression containing hold to a variable, and then call that variable, MuPAD evaluates the expression:

y := hold(int)(x^2*sin(x), x);

Was this topic helpful?