2
$\begingroup$

I have a very complicated function of three variables (a,b,c). Now I want to plot the function value as a function of a while being able to manipulate b and c. Manipulate does not work well for me as the function takes quiet some time to evaluate. Therefore I had a look at ListAnimate which works nice if I only want to vary one parameter, e.g. for a simple example:

testList = Table[Plot[a*x^2, {x, -2, 2}, PlotRange -> {0.0, 4.0}], {a, 0.1, 1.0, 0.01}];

ListAnimate[testList]  

How can I expand this to work for two variables meaning that I want to have two sliders to move through either direction of this matrix of plots.

The following example gives me an animated List instead of two sliders:

testList = Table[Plot[a*x^2/x^(b*0.1), {x, -2, 2}, PlotRange -> {0.0, 4.0}], {a, 0.1, 1.0, 0.01}, {b, 1., 10., 1.}];

ListAnimate[testList]
$\endgroup$

1 Answer 1

1
$\begingroup$

Maybe Manipulate can still be useful:

ClearAll[plot];
Do[
  plot[a, b] = 
   Plot[a*(x - b)^2, {x, -5, 5}, PlotRange -> {{-5, 5}, {0.0, 4.0}}],
  {a, .1, 1.0, 0.1}, {b, 0, 1, .1}];


Manipulate[
 plot[a, b]
 ,
  {a, .1, 1.0, 0.1}, {b, 0., 1, .1}
  ]

Keep in mind that the number of frames you want to precalculate is growing fast with number of parameters and resolution.

$\endgroup$
3
  • 1
    $\begingroup$ Or just Manipulate[testList[[n, m]], {n, 1, Length@testList, 1}, {m, 1, Length@testList[[1]], 1}]. $\endgroup$
    – Karsten7
    Mar 11, 2015 at 14:06
  • $\begingroup$ @Karsten7. yes, I don't know why I went DownValues way. $\endgroup$
    – Kuba
    Mar 11, 2015 at 14:17
  • 1
    $\begingroup$ @Karsten7. oh I know, because in your way you have to convert indices to values if you want to show parameters state. Not a big deal but this way is shorter. $\endgroup$
    – Kuba
    Mar 11, 2015 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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