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.
Evaluation is one of the most common mathematical operations.
Therefore, it is important to understand how and when MuPAD^{®} performs
evaluations. For example, assign the value 2 + 2
to
the variable y
. Instead of assigning the expression 2 + 2
, MuPAD evaluates this
expression, and assigns the result of the evaluation, the value 4,
to the variable y
:
y := 2 + 2: y
The variable y
is an identifier, and the
number 4 is the value of that identifier. Values of identifiers are
not always numbers. For example, a value of an identifier can also
contain identifiers. In the following assignment, y
is
an identifier, and the expression a + x
is
the value of that identifier:
y := a + x
The value of y
is a sum of two identifiers, a
and x
.
You can assign a value to any of these identifiers. For example, assign
the value 10 to the identifier a
. Now, MuPAD recognizes
that a
is equal to 10. Therefore, the system evaluates
the value a + x
of the identifier y
to
the expression x + 10
:
a := 10: y
Note: The value of an identifier is the value computed at the time of assignment. |
The value of the identifier y
is still x + a
.
If you assign any other value to a
, MuPAD evaluates y
using
this new value:
a := 15: y
Now, assign the value 10 to the identifier a
,
and then assign the expression x + a
to y
.
As in the previous example, MuPAD evaluates the identifier y
and
returns the expression x + 10
:
a := 10: y := a + x: y
Although the evaluation returns the same result as in the previous
example, the value of y
is different. Here the
value of y
is the expression x + 10
.
This value does not depend of the identifier a
:
a := 15: y
For further computations, clear the identifiers a
, x
,
and y
:
delete a, x, y
The value of an identifier can be any MuPAD object. For example, the value of an identifier can be a list:
list := [x^k $ k = 1..10]
If later you assign the value to x
, the evaluation
of the identifier list
changes accordingly:
x := 1/2: list
MuPAD applies the same evaluation mechanism to function
names. For example, assign the function call f( π )
to
the identifier y
:
y := f(PI)
Now, assign the function sin
to f
.
If you evaluate the identifier y
, the system replaces
the identifier f
by its value sin
.
Then, the system evaluates the call sin( π )
and
returns 0:
f := sin: y
If you change or delete the value of f
, the
evaluation of f( π )
changes accordingly:
f := cos: y
delete f: y