I struggled with the Mathematica Manipulate feature over the last few days for a project.
I am working on customizing the assumptions and boundary conditions that go into the physical model. To do this, I want to be able to build various equations and adjust parameters and update graphs on the fly. Manipulation seems like the perfect tool for the job - except that I can't get it to work. Charts will not be updated when parameters are changed.
Basic example:
a =.; b =.; c =.; func1[x_] := a*x; func2[x_] := a*x^2 + b*x + c; funcNamesList := {"Linear", "Quadratic"}; funcList := {func1[x], func2[x]} Manipulate[ Plot[function, {x, -5, 5}], {function,MapThread[Function[
I can get, for example, func1 to update by pressing func1 , adjusting a , then pressing func1 again, but I hope it refreshes when I adjust a , because the real functions that I use are pretty temperamental to their parameters.
-Because I will deal with long functions that have different parameters, it is useful to use a list of functions.
EDIT:
In case it gives any ideas for everyone, here are some working examples of the individual components of what I want to do (from the Wolfram documentation):
Graph graphs and update them when changing parameters:
Manipulate[ Plot[Sin[ax + b], {x, 0, 6}], {{a, 2, "Multiplier"}, 1, 4}, {{b, 0, "Phase Parameter"}, 0, 10} ]
Note. This is interrupted when the function is taken externally:
func[x] := Sin[ax + b]; Manipulate[ Plot[func[x], {x, 0, 6}], {{a, 2, "Multiplier"}, 1, 4}, {{b, 0, "Phase Parameter"}, 0, 10}, LocalizeVariables -> False ]
Example of changing the displayed function:
Manipulate[ Plot[f[x], {x, 0, 2 Pi}], {f, {Sin -> "sine", Cos -> "cosine", Tan -> "tangent"}} ]
Edit 2 Func2 has been changed from a*x^2 to a*x^2 + b*x + c to reflect the fact that functions can have different parameters.
Edit 3 Added a tidbit that I use to get nice names on function buttons.