MathGroup Archive 2010

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

Search the Archive

Re: Plotting a function dynamically in a loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112905] Re: Plotting a function dynamically in a loop
  • From: "Nasser M. Abbasi" <nma at 12000.org>
  • Date: Tue, 5 Oct 2010 05:36:06 -0400 (EDT)
  • References: <i8c8ub$g9p$1@smc.vnet.net>
  • Reply-to: nma at 12000.org

On 10/4/2010 3:06 AM, ABHIJIT BHATTACHARYYA wrote:
> Hi!
>
>   Let us consider that I have one 3D array ex[[i,j,k]] which is computed
>   in time loop as given here.
>
>   alfa=0.3; beta=0.4; gamma== 0.5;=0A For[time=0, time<= maxtime, time++,
>   Do[ex[[i,j,k]] = alfa*i+beta*j+gamma*k, {i,1,imax}, {j,2,jmax+1},{k,1,kmax}]
>
>   (* Plot ex[[]]= dynamically *)
>   ]
>
> What I want is that I like to plot ex[[i,j,k]] at every time step in a  single plot so that plot is revealed as a movie.  Is it possible in
>   mathematica?
>
>   Regs
>   Abhijit Bhattacharyya


This is the main difference between Mathematica and other handler 
graphics based systems.

There is no "handler" to some canvas to use to send all output to. Doing 
this

Do[Print@Plot[Sin[a x], {x, -Pi, Pi}], {a, 1, 10}]

Will just show all the plots.

But you can use many other options in Mathematics to do the same.

Such as

Animate[Plot[Sin[a x], {x, -Pi, Pi}], {a, 1, 10}]

or

ListAnimate[Table[Plot[Sin[a x], {x, -Pi, Pi}], {a, 1, 5}]]

or make a Dynamic expression that depends on parameter, and then change 
the parameter later, this will cause the Dynamic expression to be 
re-evaluated automatically each time the parameter changed. Use Pause to 
slow the loop:

Dynamic[Plot[Sin[a x], {x, -Pi, Pi}]]
Do[a = i; Pause[1], {i, 0, 10}]

And many other ways to do this I am sure.

--Nasser



  • Prev by Date: Re: How to apply a list of functions
  • Next by Date: Re: How to apply a list of functions
  • Previous by thread: Re: Plotting a function dynamically in a loop
  • Next by thread: Re: Plotting a function dynamically in a loop