1
$\begingroup$

I have a list of Values and a list of variables. I want to set the Values into Variables.

Assume the following code:

Values = {{1, 2}, {3, 4}, {5, 6}};
VariableS = {{x1, x2}, {x3, x4}, {x5, x6}};

VariableS[[1]] = Values[[1]];

FIntegrate = Integrate[f[x], {x, x1, x2}]

I want to use {x1, x2}={1, 2} and get x1=1 and x2=2 and finally caculate the definite IntegralFIntegrate .But I can not set the x1=1 and x2=2.

How can I to do that ?

$\endgroup$
0
1
$\begingroup$

You can do that this way:

Values = {{1, 2}, {3, 4}, {5, 6}};
VariableS = {{x1, x2}, {x3, x4}, {x5, x6}};

MapThread[Set, {VariableS, Values}, 2];
Integrate[Sin[x], {x, x1, x2}]
 Cos[1] - Cos[2]

Your way is not working because VariableS[[1]] = Values[[1]]; sets the value of the first element of VariableS not the symbol names stored there.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.