MathGroup Archive 1995

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

Search the Archive

Re: Problem: Plotting list of {InterpolatingFunction[]}

  • Subject: [mg2585] Re: Problem: Plotting list of {InterpolatingFunction[]}
  • From: rknapp (Robert Knapp)
  • Date: Mon, 27 Nov 1995 21:31:42 -0500
  • Approved: usenet@wri.com
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.

In article <DI9AuM.Bx at wri.com> Patrick Jemmer <paddy at sun4.bham.ac.uk> writes:

> 
> Hello all: I am solving a set of DEs using NDSolve to produce
> a list of interpolating functions, where the list is called ans:
> 
> 
> In[5]:= ans
> 
> Out[5]= {{source[t] -> InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >     sink[t] -> InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >     conc[t] -> InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >     a1[t] -> InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >     b1[t] -> InterpolatingFunction[{0., 1.}, <>][t]}}
> 
> I then substitute with the list sp={source[t], sink[t], ... }
> 
> intpf =sp/. ans
> 
> Out[6]= {InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >    InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >    InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >    InterpolatingFunction[{0., 1.}, <>][t], 
>  
> >    InterpolatingFunction[{0., 1.}, <>][t]}
> 
> 
> 
> I am then trying to plot these together:
> 
> Plot[intpf,{t,0,1}]In[7]:= Plot[intpf,{t,0,1}]
> 
...
> and an empty plot....

You are running into problems with the HoldAll attribute of Plot.
Your problem has nothing to do with InterpolatingFunction objects per
se.  For example:


vec = {x^2,x^3};
Plot[vec,{x,0,1}]

does the same thing.  Why?  Because Plot does not evaluate its
argument, it sees one item and assumes that it is to plot something
which evaluates to a real number for each value of x--not a vector.


The solution:  wrap Evaluate[] around the first argument, as in

vec = {x^2,x^3};
Plot[Evaluate[vec],{x,0,1}]

or

Plot[Evaluate[intpf],{t,0,1}]

and you should get what you want.








Rob Knapp
WRI


  • Prev by Date: Re: Why no simplification ?
  • Next by Date: Math Question
  • Previous by thread: Problem: Plotting list of {InterpolatingFunction[]}
  • Next by thread: Re: Problem: Plotting list of {InterpolatingFunction[]}