I have two nested For-loops in my code. I would like all the results to be in one table, as shown below. My problem is that I want to print with ListPlot
from this table all the solutions in one graph, but with k
as parameter, i.e., to have 10 different graphs in one. I think that the solution would be to save k
like in an excel I would save it in separate sheets, but I don't find a way to do this. Could somebody help me with my idea or suggest something else? Thanks!
Results = {};
For[k = 1, k < 11, k = k + 1,
For[b = 1, b < 5, b = b + 0.5,
sol = NSolve[2 k + b - c - 10 == 0, c];
AppendTo[Results, Flatten@{k, b, c /. sol}];]]
Results
For
is almost always the wrong way to approach a solution in Mathematica. Although it does exist in the language, importing code of this paradigm from other languages is very likely to just complicate your life with no additional benefit. $\endgroup$ – kirma Sep 11 '18 at 14:39