1
$\begingroup$

I'm new to Mathematica. I am trying to create a graph that can change through user interface in more than just the variables. Ideally, I want the user to click a button and have the equation change from a linear equation to an exponential equation, for example, and then change the variables with sliders. I have the sliders, but I'm not sure how to change the equation itself. My code so far is as follows:

Manipulate[Plot[a*x+b, {x,-5, 6}], {a, -5, 5}, {b, -5, 5}]

enter image description here

Manipulate[Plot[a*b^x + c, {x, -5, 6}], {a, -5, 5}, {b, 0.01, 5}, {c, -5, 5}]

enter image description here

$\endgroup$
2
$\begingroup$
TabView[
 {"Linear:  a x + b" -> 
   Manipulate[Plot[a x + b, {x, -5, 6}], {a, -5, 5}, {b, -5, 5}], 
  "Exponential:  a \!\(\*SuperscriptBox[\(b\), \(x\)]\) + c" -> 
   Manipulate[
    Plot[a b^x + c, {x, -5, 6}], {a, -5, 5}, {b, 1, 5}, {c, -5, 5}]} ]

Do you really want b to take on negative values in the Exponential function?

You can also try MenuView, which may be preferable if you have many functions.

$\endgroup$
2
  • $\begingroup$ That's a good point; no, b probably doesn't need to take on negative values in the exponential function. $\endgroup$ – heather Jun 17 '16 at 18:26
  • $\begingroup$ Thanks, it works! I changed the lower bound for b to 0.01 and there were no errors. $\endgroup$ – heather Jun 17 '16 at 18:30

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.