manipulate plot
- To: mathgroup at smc.vnet.net
- Subject: [mg107378] manipulate plot
- From: you can call me al <misterraum at gmail.com>
- Date: Thu, 11 Feb 2010 05:18:27 -0500 (EST)
Hi all, Often after arriving at the result of some calculation in Mathematica I have an expression in many variables and would like to plot the function inside of a manipulate box so that I can observe the effect of changing the parameters. To make the discussion here more concrete let's say I have y = f(x,a,b) A natural thing to try to do is something like: Manipulate[Plot[y,{x,0,1}],{a,0,1},{b,0,1},....] This of course fails to produce output seemingly because Mathematica can't understand that f is actually an expression in the variables x,a, and b. It seems that the only way to get what I'm after is to go through a lot of syntactic acrobatics geared at turning the results of my calculations (which are usually just algebraic expressions) into some sort of function definition. This is generally a huge pain in the ass and also tends to clutter and obfuscate the notebook that I'm working in. So.... When I'D LIKE to do this: y = m x; Manipulate[Plot[y,{x,0,1}],{{m,1},0,2}]; I MUST INSTEAD do either: Manipulate[Plot[m x,{x,0,1},PlotRange->{0,2}],{{m,1},0,2}] -OR- y = Function[{m,x},m x]; Manipulate[Plot[y[m,x],{x,0,1},PlotRange->{0,2}],{{m,1},0,2}] -OR- y[m_,x_] := m x; Manipulate[Plot[y[m,x],{x,0,1},PlotRange->{0,2}],{{m,1},0,2}] or god knows what else... In the example above the problem doesn't seem so bad but when the expressions become larger functions of more variables and/or I'm plotting more than one function then the constructs above start to get unweildly and I start really wondering why there is no support for me to type something like: Manipulate[Plot[{f1,f2,f3},{x,0,1}],{a,0,1},{b,0,1}] RATHER THAN: Manipulate[Plot[{Exp[-(a-b)*x],Exp[-a*x]Cos[2*Pi*b*x],Exp[- a*x]*Sin[2*Pi*b*x]},{x,0,1}],{a,0,1},{b,0,1}] -OR- f1 = Function[{a,b,x},Exp[-(a-b)*x]]; f2 = Function[{a,b,x},Exp[-a*x]Cos[2*Pi*b*x]]; f3 = Function[{a,b,x},Exp[-a*x]Cos[2*Pi*b*x]]; Manipulate[Plot[f1[a,b,x],f2[a,b,x],f3[a,b,x]},{x,0,1}],{a,0,1},{b, 0,1}] -OR- f1[a_,b_,x_] = Exp[-(a-b)*x]; f2[a_,b_,x_] = Exp[-a*x]Cos[2*Pi*b*x]; f3[a_,b_,x_] = Exp[-a*x]Cos[2*Pi*b*x]; Manipulate[Plot[f1[a,b,x],f2[a,b,x],f3[a,b,x]},{x,0,1}],{a,0,1},{b, 0,1}] I've often wondered if there is something I don't know about this. If there are any tricks out there to simplify the use of the Manipulate[Plot[{my_algebraic_results},{x,0,1}],my_parameters] construct i'd really love to hear them. I think the Manipulate functionality is VERY attractive but i'm always VERY frustrated that I usually have to bend over backwards to operate it in anything but the simplest context. Thanks in advance, hopeful
- Follow-Ups:
- Re: manipulate plot
- From: Carl Woll <carlw@wolfram.com>
- Re: manipulate plot
- From: bsyehuda@gmail.com
- Re: manipulate plot