The ContourPlot is applied 5 times with this code:

i = Range[1, 5]
j = Range[1, 5]
ContourPlot[x^2/i + y^2/j == 1, {x, -5, 5}, {y, -5, 5}]

However, I would like it to be applied 5 separate times for each 5 values of i (so 25 times in total). So a plot for (i=1 and j=1), (i=1 and j=2), (i=1 and j=3)... etc.

How do I create such a nested loop?

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Dr. belisarius Oct 12 '15 at 21:45
Show[ContourPlot[x^2/#1 + y^2/#2== 1,{x, -5, 5},{y, -5, 5}] & @@@ Tuples[Range@5, {2}]]

Mathematica graphics


Using Table:

Table[ContourPlot[x^2/i + y^2/j == 1, {x, -5, 5}, {y, -5, 5}], {i, 5}, {j, 5}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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