MathGroup Archive 2008

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

Search the Archive

How to animate a (scrolling) ListPlot in a procedural Mathematica program?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93717] How to animate a (scrolling) ListPlot in a procedural Mathematica program?
  • From: Chrisantha Fernando <ctf20 at sussex.ac.uk>
  • Date: Mon, 24 Nov 2008 04:11:23 -0500 (EST)
  • References: <eslsqe$q5a$1@smc.vnet.net> <200703080944.EAA15028@smc.vnet.net>

Dear Mathgroup,

Currently I have the following code. It is procedural, and goes  
through the while loop generating two arrays, V and U of L = 1000 in  
length, that slides through from i = 0 to 10000, storing the changing  
values of v and u.

I only know how to plot the output of V and U arrays at the END. After  
all this is done.

HOWEVER, I'd really like to be able to visualize the V and U arrays  
whilst the program was running.

How can I do this? I think it needs Manipulate, but I can't work it  
out from the examples.

Many Thanks,
Chrisantha Fernando.
National Institute for Medical Research
London, UK


a = 0.02;
b = 0.20;
c = -65;
d = 6;
Inp = 14;

L = 1000;

v = -70;
u = -20;

V = ConstantArray[v, L];
U = ConstantArray[u, L];

tau = 0.2;
t = 0;
i = 0;

While[i < 10000,
   i = i + 1 ;
   t = t + tau;
   v = v + tau*(0.04*v^2.0 + 5*v + 140 - u + Inp);
   u = u + tau*a*(b*v - u);
   If[v > 30, v = c ; u = u + d;   V[[1]] = 31; h = 0; ];
   V = Prepend[Drop[V, -1], v];
   U = Prepend[Drop[U, -1], u];

   ];

V = Reverse[V];
U = Reverse[U];

Vplot = ListPlot[V, PlotJoined -> True, PlotRange -> All]
Uplot = ListPlot[U, PlotJoined -> True, PlotRange -> All]
VU = ListPlot[Table[{V[[i]], U[[i]]}, {i, 1, L}], PlotJoined -> True,
   PlotRange -> { {-100, 20}, {-40, 50}}]




  • Prev by Date: Re: FFT in Mathematica
  • Next by Date: Re: Creating a Banner -> Now creating a slide show
  • Previous by thread: Re: Re: Primed Symbols in Mathematica
  • Next by thread: Flow around sections and subsections!