clarification. Re: one liner for a function?
- To: mathgroup at smc.vnet.net
 - Subject: [mg45983] clarification. Re: one liner for a function?
 - From: sean_incali at yahoo.com (sean kim)
 - Date: Sat, 31 Jan 2004 05:21:08 -0500 (EST)
 - Sender: owner-wri-mathgroup at wolfram.com
 
Thanks Bob, for the helpful comments from past few days. I'm
constantly amazed at you guys for being so helpful.
What I was trying to do in my last post was to make a function that
uses another function to make commands that will make graphs.
i have a function called pfunc, 
pfunc[name_] := Plot[Evaluate[{name[t] /. sol}, {t, 0, 250}],
PlotRange -> All, DisplayFunction -> Identity, PlotLabel -> name];
The new function has to take a list called var= {a[t], b[t], x[t],
y[t]}
and then generate two types of mathematica commands.
1. write lines that applies pfunc to each of the elements,while giving
that each name according to the variable name, ie.
pa = pfunc[a]; pb = pfunc[b]; px = pfunc[x]; py = pfunc[y];
2. take those new names for the plots, then make a show GraphicArray
commands with *two* column of plots, ie.
Show[GraphicsArray [{{pa, pb}, {px, py}}], ImageSize -> 500]
this one below doesn't work with the following errors. 
Show::gtype: Symbol is not a type of graphics
In[22]:=
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]];
var = {a[t], b[t], x[t], y[t]};
(* a function to make (pa = pfunc[a]; pb = pfunc[b]; px = pfunc[x]; py
= pfunc[y];)*)
plfunc[name_]:= StringJoin["p","name"]//ToExpression =
Plot[Evaluate[{name/. sol}, {t, 0, 100}], PlotRange-> All,
DisplayFunction-> Identity, PlotLabel-> name];
Apply[plfunc,Flatten[var]]
(* i can't figure out how to make a function for this one*)
Show[GraphicsArray [{{pa, pb}, {px, py}}], ImageSize-> 500]