Hi, I have a problem:
I use Solve to get the solutions of equations, but here comes the problem. I seem to be unable to find an easy way to assign all the outputs of Solve to variables with the same name at once.
Now I have six outputs and I want to assign them to the variables with the same name. E. g. Solve gives me {var1 → 14515} and I want to assign to variable called ‘var1’. I know it can somehow be done by /.sol[[1]] etc., but I’d like to assign them all at once without having to list every variable and assign it extra.
As you can see, it doesn’t work since the variables which the equations are solved for aren’t assigned. What am I doing wrong? Thank you
P. S. I know these are simple equations but Mathematica is new to me so I try to use it as much as possible to get used to it, and solution of this problem could be useful in the future.
I apologize. I made two mistakes. First I wrote the line claiming it would solve your problem. Second I did not test that before posting. I should be better than that.
Please try this correction
(* evaluate your code prior to your solve and then this code *)
sol = Solve[{r1, r2, r3, r4, r5, r6}, vars][[1]];
MapThread[Set, {vars, vars /. sol}];
(* and then look at the value assigned to your variables *)
nF1
(* and *)
nD1
(* and ... *)
I just checked this and I believe I have corrected my mistake.
Thank you for checking what I did and reporting my mistake.