MathGroup Archive 2009

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

Search the Archive

Re: Plotting in a dynamic environment.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99636] Re: Plotting in a dynamic environment.
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Sun, 10 May 2009 05:13:52 -0400 (EDT)
  • References: <gu3at0$t8t$1@smc.vnet.net>

Hi Marcel,

You should make the dependence of myfun on x and t explicit. That's
always a good idea, but for Manipulate to work it should be able to
'see' that changing t does something to the object that is the focus
of the Manipulate construct. In addition, the Evaluate you used is not
necessary here.

This works:

myfun[x_, t_] := x^2 + 3 t x;
t = 1;
Plot[myfun[x, t], {x, 0, 2}]
Clear[t]
Manipulate[myfun[x, t]] {x, 1, 2}, {{t, 1}, 0, 10}]
Manipulate[Plot[myfun[x, t], {x, 1, 2}], {{t, 1}, 0, 10}]

Cheers -- Sjoerd

On May 9, 9:21 am, mgoic <mag... at gmail.com> wrote:
> Hi everyone,
>
> I am having problems when trying to plot an expression in a Dynamic
> model using manipulate tool. For example, in this simple code I can
> plot the function (first plot), I can evaluate its value in a
> manipulate environment (second plot), but when trying to plot in a
> dynamic environment I just get empty axis (third plot).
>
> myfun = x^2 + 3 t x ;
> t = 1;
> Plot[myfun, {x, 0, 2}]
> Clear[t]
> Manipulate[Evaluate[myfun], {x, 1, 2}, {{t, 1}, 0, 10}]
> Manipulate[Plot[Evaluate[myfun], {x, 1, 2}], {{t, 1}, 0, 10}]
>
> Any idea of what I am doing wrong? I will really appreciate any
> guidance.
>
> Regards,
> Marcel Goic



  • Prev by Date: Re: Plotting in a dynamic environment.
  • Next by Date: Re: Replace specific element with specific value.
  • Previous by thread: Re: Plotting in a dynamic environment.
  • Next by thread: Re: Plotting in a dynamic environment.