`assign`

Perform assignments given as equations

**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.**

assign(`L`

) assign(`L`

,`S`

)

For each equation in a list, a set, or a table of equations `L`

, `assign(L)`

evaluates both sides of the equation and assigns the
evaluated right hand side to the evaluated left hand side.

`assign(L, S)`

does the same, but only for
those equations whose left hand side is in the set `S`

.

Since the arguments of `assign`

are evaluated,
the *evaluation* of the left hand side of each
equation in `L`

must be an admissible left hand side
for an assignment. See the help page of the assignment operator `:=`

for
details.

Several assignments are performed from left to right. See Example 4.

`assign`

can be conveniently used after a call
to `solve`

to assign
a particular solution of a system of equations to the unknowns. See Example 5.

We assign values to the three identifiers `B1,B2,B3`

:

delete B1, B2, B3: assign([B1 = 42, B2 = 13, B3 = 666]): B1, B2, B3

We specify a second argument to carry out only those assignments
with left hand side `B1`

:

delete B1, B2, B3: assign([B1 = 42, B2 = 13, B3 = 666], {B1}): B1, B2, B3

The first argument may also be a table of equations:

delete B1, B2, B3: assign(table(B1 = 42, B2 = 13, B3 = 666)): B1, B2, B3

Unlike `_assign`

, `assign`

evaluates
the left hand sides:

delete a, b: a := b: assign({a = 3}): a, b

delete a, b: a := b: a := 3: a, b

The object assigned may also be a sequence:

assign([X=(2,7)])

X

The assignments are carried out one after another, from left
to right. Since the right hand side is evaluated, the identifier `C`

gets
the value `3`

in the following example:

assign([B=3, C=B])

level(C,1)

When called for an algebraic system, `solve`

often returns a set of lists of
assignments. `assign`

can then be used to assign
the solutions to the variables of the system:

sys:={x^2+y^2=2, x+y=5}: S:= solve(sys)

We want to check whether the first solution is really a solution:

assign(S[1]): sys

Things become clearer if we use floating-point evaluation:

float(sys)

`L`

.