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

I am an R user and am totally new to Mathematica. I am trying to find the roots of a system of two equations over a series of paramter values and plot the results. I can do the computation but would love to know how I can work with the results without exporting them from Mathmatica.

 alphas = Table[
          FindRoot[ {
          S1*(1 - Exp[-R01*(1 - alpha)*Zinf1/N1 - R02*alpha*Zinf2/N2]) - Zinf1,
          S2*(1 - Exp[-R02*(1 - alpha)*Zinf2/N2 - R01*alpha*Zinf1/N1]) - Zinf2} == 0, 
          {Zinf1, 10000},
          {Zinf2, 10000}], {alpha, 0, 1, .1}]

This seems to return a list of named lists (each element being something like {Zinf1 -> 9403.65, Zinf2 -> 9800.66}). I would like to plot all the Zinf1's vs. alphas and thought something like ListPlot[] could do it, but it seems to have issues with the name:

ListPlot::optx: Unknown option Zinf1 in ListPlot[Zinf1->9403.65,Zinf1->9475.33,Zinf1-    9533.97,Zinf1->....

Any idea how to get this data into an easier (perhaps unnamed) form?

share|improve this question
Try the following: ListPlot[{Zinf1, Zinf2} /. alphas] This will allow for each replacement of the Zinf1's and Zinf2's one by one from the solutions. – Jonathan Shock Jun 7 '13 at 16:04
Thanks! Feel free to post that as a solution. – scottyaz Jun 7 '13 at 16:06
up vote 3 down vote accepted

alpha1 has given you a Table of replacements. You just need to create something in which you can make these replacements. A command of the form {a,b}/.{a->1,b->2} will give you {1,2}. Similarly in this case you can pass the whole table in as follows:

ListPlot[{Zinf1, Zinf2} /. alphas]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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