evalassign
Assignment with evaluation of the left hand side
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.
evalassign(x
,value
,i
) evalassign(x
,value
)
evalassign(x, value, i)
evaluates x
with
substitution depth i
and assigns value
to
the result of the evaluation.
evalassign(x, value, i)
evaluates value
,
as usual. Then it evaluates x
with substitution
depth i
, and finally it assigns the evaluation
of value
to the evaluation of x
.
The difference between evalassign
and the
assignment operator :=
is that the latter does not evaluate
its left hand side at all.
As usual, the evaluation of value
takes place
with substitution depth given by LEVEL
. By default, it is 1
within
a procedure.
See the help pages of LEVEL
and level
for the notion
of substitution depth and for details about evaluation.
The third argument is optional. The calls evalassign(x,
value)
, evalassign(x, value, 0)
, x
:= value
, and _assign(x, value)
are all
equivalent.
The result of the evaluation of x
must be
a valid left hand side for an assignment. See the help page of :=
for
details.
The second argument is not flattened. Hence it may also be a sequence. Cf. Example 2.
evalassign
can be used in situations such
as the following. Suppose that an identifiera
has
another identifier b
as its value, and that we
want to assign something to this value of a
,
not to a
itself:
delete a, b: a := b: evalassign(a, 100, 1): level(a, 1), a, b
This would not have worked with the assignment operator :=
,
which does not evaluate its left hand side:
delete a, b: a := b: a := 100: level(a, 1), a, b
The second argument may also be a sequence:
a := b: evalassign(a, (3,5), 1): b

An object that evaluates to a valid left hand side of an assignment 

Any MuPAD^{®} object 

A nonnegative integer less than 2^{31} 
value
.