Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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

marked as duplicate by Mr.Wizard Jun 26 '15 at 17:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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.