Sunday, May 18, 2008

Interactive Plots in Mathematica

To study the behavior of an analytical solution that has several control parameters, one would usually plot that function under different combinations of these parameters. There is a super nice function in Mathematica that allows the user to dynamically plot the solution by changing the control parameters using sliders. The function is called Manipulate and here's an example
Manipulate[Plot[Exp[-w x] Cos[a x], {x, 0, 3 Pi}, PlotRange -> Full], {w, 0, 10}, {a, 0,20}]
Voila!
The Manipulate[] function performs a job similar to that of the Table[] function, but with a graphical user interface. In the above code, we are manipulating a plot subject to two control parameters, w and a. The Plot[] function follows the standard Mathematica syntax. Here's a screen recording of how the result looks like



Of course, you can plot as many functions and accomodate as many control parameters as you want. This also works with 3D plots. Of course, you will have to use Plot3D to do that.

For a complete description of the Manipulate function, you can visit its Mathematica documentation page
http://reference.wolfram.com/mathematica/tutorial/IntroductionToManipulate.html

Cite as:
Saad, T. "Interactive Plots in Mathematica". Weblog entry from Please Make A Note. http://pleasemakeanote.blogspot.com/2008/05/interactive-plots-in-mathematica.html

3 comments:

  1. Sir
    how to plot the derivative of
    f(x)=Exp[x]/(4*Exp[x]+1)

    ReplyDelete
  2. Plot[D[Exp[x]/(4*Exp[x]+1),x],{x,0,10}]

    ReplyDelete
  3. This is very clever stuff, interesting point of view, I wonder if the results are measurable.
    Cheap Viagra Online

    ReplyDelete