1
$\begingroup$

I have a function which depends on three parameters, and I would like to see how it changes as I vary those. I created three sliders, used Dynamic and what I obtain seems to work, in the sense that indeed the function outputs values which are correct and are updated in real-time if I move the sliders.

The problem is that there is no way for me to plot those values. I tried in many different ways (with Dynamic inside or outside, with Evaluate): nope. Why can't I plot a function which correctly returns values?

{"A", Slider[Dynamic[A]], Dynamic[A*100]}
{"α", Slider[Dynamic[α]], Dynamic[α*100]}
{"β", Slider[Dynamic[β]], Dynamic[β + 1]}
σ[ϵ_] = 
 Dynamic[A*100*(Exp[α*100*ϵ] - 1)/(1 + 
      Exp[(β + 1)*α*100*ϵ])]
σ[.001]
Plot[σ[ϵ], {ϵ, 0, 1}]
$\endgroup$

1 Answer 1

2
$\begingroup$

Manipulate is exactly what you are looking for, rather than re-constructing this functionality by hand using Dynamic, which is often more challenging to use:

Manipulate[
 Plot[
   A*100*(Exp[α*100*ϵ] - 1)/(1 + Exp[(β + 1)*α*100*ϵ]),
   {ϵ, 0, 1},
   PlotRange -> All
 ],
 {A, 0, 100}, {α, 0, 100}, {β, 0, 1}
]

enter image description here

Manipulate is very powerful and flexible, and well-worth getting acquainted with: as you look into its documentation, you will also find examples to set the initial values of the parameters, to label them, and much more.

$\endgroup$
2
  • $\begingroup$ Wow! Thank you! I thought that Manipulate could be used with a single parameter only. Indeed, this is exactly what I was looking for 🙂 $\endgroup$
    – gwaedin
    Commented Dec 18, 2023 at 20:16
  • $\begingroup$ @gwaedin I'm glad this helps! If you think this answers your question to your satisfaction, consider accepting this answer by clicking on the grey checkmark beside it. $\endgroup$
    – MarcoB
    Commented Dec 20, 2023 at 2:02

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.