Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: How to animate a (scrolling) ListPlot in a procedural Mathematica

  • To: mathgroup at smc.vnet.net
  • Subject: [mg93751] Re: How to animate a (scrolling) ListPlot in a procedural Mathematica
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Mon, 24 Nov 2008 06:50:02 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <eslsqe$q5a$1@smc.vnet.net> <200703080944.EAA15028@smc.vnet.net> <ggdqr9$kc$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

try

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

L = 1000;

v = -70;
u = -20;
tau = 0.2;
t = 0;

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

Dynamic[ListPlot[{Reverse[U], Reverse[V]}]]

Do[
   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 = RotateRight[V, 1]; V[[1]] = v;
   U = RotateRight[U, 1]; U[[1]] = u; Pause[0.001],
   {i, 1, 10000}
   ];

??

Regards
  Jens


Chrisantha Fernando wrote:
> 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: Mathematica 7 is now available
  • Next by Date: Re: Integration - another Integer as a result
  • Previous by thread: Re: solve a problem in mathematica
  • Next by thread: v.7.0 issues