0
$\begingroup$

I create an interpolating function which depends on some free variables. I then want to plot it inside a manipulate, but my output is empty.

What am I doing wrong?

points = {{0, 1}, {8, low}, {12, mid}, {24, 0.1}, {35, mid}, {50, 
    low}, {end, 1}};
g = Interpolation[{0, 1}, {2, 3}, InterpolationOrder -> 1];
Manipulate[
 Plot[g,
  {x, 0, 100},
  Frame -> True,
  PlotRange -> {0, 1}
  ],
 {low, 1, 0.6, Appearance -> "Labeled"},
 {mid, 0.6, 0.2, Appearance -> "Labeled"},
 {end, 58, 100, Appearance -> "Labeled"}
 ]
$\endgroup$

1 Answer 1

1
$\begingroup$

It's not completely clear to me what you want to achieve, but see below if that's what you need:

Manipulate[
 points = {{0, 1}, {8, low}, {12, mid}, {24, 0.1}, {35, mid}, {50, 
    low}, {end, 1}};
 g = Interpolation[points, InterpolationOrder -> 1];


 Plot[g[x], {x, 0, 100}
  , Frame -> True
  , PlotRange -> {0, 1}]

 ,
 {low, 1, 0.6, Appearance -> "Labeled"},
 {mid, 0.6, 0.2, Appearance -> "Labeled"},
 {end, 58, 100, Appearance -> "Labeled"}]
$\endgroup$
2
  • $\begingroup$ thank you! this I what I was looking for. The rendering is a bit slow, is it possible to improve the speed? $\endgroup$
    – Nisba
    Jun 12, 2018 at 11:56
  • $\begingroup$ It's not the rendering to be slow, the problem is that every time you change one slider in the manipulate, MMA is calculating again the interpolation (and then plotting it, which should be fast). I'm not aware of an Interpolation function with free parameters (it sounds a bit as a contradiction to me), but maybe someone else can enlighten us about it :) $\endgroup$
    – Fraccalo
    Jun 12, 2018 at 12:03

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.