Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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 ?

share|improve this question

closed as off-topic by Artes, Verbeia Apr 15 at 12:22

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Artes, Verbeia
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 1 down vote accepted

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.

share|improve this answer

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