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: one liner for a function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg45964] Re: one liner for a function?
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Sat, 31 Jan 2004 05:20:27 -0500 (EST)
  • References: <bvd9f8$5k1$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Needs["Graphics`"];

sol=NDSolve[{a'[t]==-0.1` a[t] x[t],
          b'[t]==-0.05` b[t] y[t],
          x'[t]==-0.1` a[t] x[t]+0.05` b[t] y[t],
          y'[t]==0.1` a[t] x[t]-0.05` 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[#[[2]][t]& /@ sol],{t,0,250},
    PlotStyle->Table[Hue[(k+2)/6],{k,4}],
    Frame->True, Axes->False,
    PlotLegend->(#[[1]]& /@ sol),
    LegendPosition->{.95,-.35},ImageSize->400];

n=1;DisplayTogetherArray[
  Partition[Plot[Evaluate[#[[2]][t]],{t,0,250},
          PlotStyle->Hue[(2+n++)/6],
          PlotLabel->#[[1]],
          Frame->True, Axes->False]& /@ sol,2],
  ImageSize->400];


Bob Hanlon

In article <bvd9f8$5k1$1 at smc.vnet.net>, sean_incali at yahoo.com (sean kim) wrote:

<< 1. let's say you have to make GraphicsArray using the interpolating
functions.
I have managed to write a function that automates the plotting part,
but i haven't been able to write one that will automate plotting and
naming the plot object and showing in a graphics array.

as an example, 

sol= NDSolve[{a'[t]==-0.1` a[t] x[t], b'[t]==-0.05` b[t] y[t], 
          x'[t]==-0.1` a[t] x[t]+0.05` b[t] y[t], 
          y'[t]==0.1` a[t] x[t]-0.05` b[t] y[t], a[0]==1, b[0]==1,
x[0]==1,
          y[0]==0}, {a,b,x,y},{t,0,250}][[1]];

pfunc[name_]:= Plot[Evaluate[{name[t]/. sol}, {t, 0, 250}],
PlotRange-> All, DisplayFunction -> Identity, PlotLabel -> name];

pa = pfunc[a];
pb = pfunc[b];
px = pfunc[x];
py = pfunc[y];

Show[GraphicsArray [{{pa, pb}, {px, py}}], ImageSize-> 500]


funtion I wrote called "pfunc" does fine, but i was wondering is there
a way to automate the

pa = pfunc[a]; ... py = pfunc[y];
  
and 

Show[GraphicsArray [{{pa, pb}, {px, py}}], ImageSize-> 500] 

part also?  

I can't seem to figure out a way to take the output of function to
make another function.. and that seems to me what i have to do.. ( i
don't even know that make sense to you guys...)


2. once you have everythign in function form, can you write it in one
liner format? ( perhaps with some explanations? )


  • Prev by Date: clarification. Re: one liner for a function?
  • Next by Date: Re: Simplifying a second order eq. system
  • Previous by thread: one liner for a function?
  • Next by thread: Re: one liner for a function?