MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: question about evaluation and Manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78337] Re: question about evaluation and Manipulate
  • From: "Steve Luttrell" <steve at _removemefirst_luttrell.org.uk>
  • Date: Thu, 28 Jun 2007 06:27:22 -0400 (EDT)
  • References: <f5vqp7$iqj$1@smc.vnet.net>

This does what you want:

f[x_,a_]=a x;
Manipulate[Plot[f[x,a],{x,0,1},PlotRange->{{0,1},{0,1}}],{{a,0.5,"a"},0,1}]

Two points:
1. The variable a is localised inside Manipulate so you need to pass it as 
an argument to the function.
2. Use an explicit PlotRange to prevent the plot from adjusting its range as 
a is varied.

Steve Luttrell
West Malvern, UK

"Yaroslav Bulatov" <yaroslavvb at gmail.com> wrote in message 
news:f5vqp7$iqj$1 at smc.vnet.net...
> I'm trying to manipulate a plot where the plotted expression is a
> symbol that should be evaluated before plotting.
>
> f[x_] = a x;
> Manipulate[Plot[f[x], {x, 0, 1}], {a, 0, 1}]
>
> This doesn't work, presumably because Plot doesn't have access to the
> value of "a" set by Manipulate. So I'd like to evaluate the first
> argument Plot, but not Plot itself before Manipulate is executed, is
> there a way to do this?
>
> 




  • Prev by Date: Re: Integration variables
  • Next by Date: Re: question about evaluation and Manipulate
  • Previous by thread: Re: question about evaluation and Manipulate
  • Next by thread: Re: question about evaluation and Manipulate