Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

RE: plot thousands(?) of trajectories in single graph.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg50507] RE: [mg50489] plot thousands(?) of trajectories in single graph.
  • From: sean kim <sean_incali at yahoo.com>
  • Date: Wed, 8 Sep 2004 05:15:25 -0400 (EDT)
  • Reply-to: sean_incali at yahoo.com
  • Sender: owner-wri-mathgroup at wolfram.com

Hi David, 

I was wondering...

I understand thye With part in the code. but What
stumps me is the use of ndsolution[] part. 

it is a function defined within a
function(KimMultiplot)?  how come? 

is it so that when you call it using...

Table[Draw[Evaluate[var[tt] /. ndsolution[]], {tt, 0,
250}], {i, 1, number}] 

you would get each iteration to use the current
ndsolution? ( as opposed to the solution from previous
iteration) 

your packages are great. I really appreciate them. 

thanks in adavnce for any insights. 

sean 


--- David Park <djmp at earthlink.net> wrote:

> Sean,
> 
> With DrawGraphics I would do it the following way. I
> don't think it would
> look good to have all the functions plotted on the
> same graph because the
> way they spread out they would cover each other up.
> 
> Needs["DrawGraphics`DrawingMaster`"]
> 
> Clear[KimMultiplot];
> KimMultiplot[label_, number_, color_, title_] :=
>    Module[{ndsolution}, ndsolution[] :=
>       With[{k1 = Random[Real, {1/10, 5/10}],
>         k2 = Random[Real, {1/20, 5/20}]},
>        NDSolve[{Derivative[1][a][t] ==
> (-k1)*a[t]*x[t],
>           Derivative[1][b][t] == (-k2)*b[t]*y[t],
> Derivative[1][x][t] ==
>            (-k1)*a[t]*x[t] + k2*b[t]*y[t],
> Derivative[1][y][t] ==
>            k1*a[t]*x[t] - k2*b[t]*y[t], a[0] == 1,
> b[0] == 1, x[0] == 1,
>           y[0] == 0}, {a, b, x, y}, {t, 0,
> 250}][[1]]];
>      Draw2D[{color, Table[Draw[Evaluate[label[tt] /.
> ndsolution[]],
>          {tt, 0, 250}], {i, 1, number}]}, PlotRange
> -> All,
>       Frame -> True, PlotLabel -> title, Background
> -> Linen,
>       ImageSize -> 450]];
> 
> KimMultiplot[a, 100, Black, "100 evaluations of
> a[t]"];
> 
> KimMultiplot[b, 100, Red, "100 evaluations of
> b[t]"];
> 
> KimMultiplot[x, 100, ForestGreen, "100 evaluations
> of x[t]"];
> 
> KimMultiplot[y, 100, Blue, "100 evaluations of
> y[t]"];
> 
> David Park
> djmp at earthlink.net
> http://home.earthlink.net/~djmp/
> 
> 
> 
> 
> From: sean kim [mailto:sean_incali at yahoo.com]
To: mathgroup at smc.vnet.net
> 
> hello group,
> 
> I have a routein that solves a system of odes over a
> parameter space thousands of times while randomly
> varying the values.
> 
> What I would like to do is take a variable and the
> resulting solutions(however many routine has
> generated
> over the course of evaluation) and plot them on
> single
> graph.
> 
> So you will get rather messy graph, but nonetheless
> shows possible trajectories given system can yield.
> 
> How do I go about doing this?
> 
> I thought i could save the interpolating functions
> and
> then evaluate thousands at the end of a routine and
> show together. But How do I save the interpolating
> function?
> 
> or do I plot with inside the module with
> DisplayFunction-> Identity and then save the plot
> and
> DisplayTogether the thousands of graphs at the end
> of
> the routine.
> 
> if doing thousands isn't possible, is it possible to
> show hundreds of trajectories?
> 
> thanks in advance for any insights.
> 
> 
> sean
> 
> code below is a example skeletal code for running
> hundred random solutions of an ode system.
> 
> 
> Do[
> Module[{},
> k1 = Random[Real, {1/10, 5/10}];
> k2 = Random[Real, {1/20, 5/20}];
> ndsolution =
> NDSolve[{a'[t] == -k1  a[t] x[t], b'[t] == -k2 b[t]
> y[t], x'[t] == -k1 a[t] x[t] + k2 b[t] y[t], y'[t]
> ==
> k1 a[t] x[t] - k2  b[t] y[t], a[0] == 1, b[0] == 1,
> x[0] == 1, y[0] == 0},{a, b, x, y}, {t, 0,
> 250}][[1]];
> Plot[Evaluate[{a[t], b[t], x[t], y[t]} /.
> ndsolution],
> {t, 0, 250}, PlotRange -> All, PlotStyle ->
> {{AbsoluteThickness[2], RGBColor[0, 0, 0]},
> {AbsoluteThickness[2], RGBColor[.7, 0, 0]},
> {AbsoluteThickness[2], RGBColor[0, .7, 0]},
> {AbsoluteThickness[2], RGBColor[0, 0, .7]}}, Axes ->
> False, Frame -> True, PlotLabel -> StyleForm[A
> StyleForm[" B", FontColor -> RGBColor[.7, 0, 0]]
> StyleForm[" X", FontColor -> RGBColor[0, .7,
> 0]]StyleForm[" Y", FontColor -> RGBColor[0, 0, .7]],
> FontFamily -> "Helvetica", FontWeight -> "Bold"]];
> ]
> ,{i, 100}]
> 
> 
> 
> 
> 
> _______________________________
> Do you Yahoo!?
> Win 1 of 4,000 free domain names from Yahoo! Enter
> now.
> http://promotions.yahoo.com/goldrush
> 
> 
> 
> 



		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail


  • Prev by Date: Re: plot thousands(?) of trajectories in single graph.
  • Next by Date: Re: Parallel Toolkit Example
  • Previous by thread: Re: plot thousands(?) of trajectories in single graph.
  • Next by thread: Re: plot thousands(?) of trajectories in single graph.