Accelerating the pace of engineering and science

# evalassign

Assignment with evaluation of the left hand side

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```evalassign(x, value, i)
evalassign(x, value)
```

## Description

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.

## Examples

### Example 1

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```

### Example 2

The second argument may also be a sequence:

```a := b:
evalassign(a, (3,5), 1):
b```

## Parameters

 x An object that evaluates to a valid left hand side of an assignment value Any MuPAD® object i A nonnegative integer less than 231

value.

## Algorithms

The function level is used for the evaluation of x. Hence i may exceed the value of LEVEL.

All special rules for _assign apply: see there on further details on indexed assignments, assignments to slots, and the protect mechanism.