MathGroup Archive 2006

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

Search the Archive

Re: Reconstructing data points from a InterpolatingFunction object

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66504] Re: Reconstructing data points from a InterpolatingFunction object
  • From: Peter Pein <petsie at dordos.net>
  • Date: Wed, 17 May 2006 03:29:51 -0400 (EDT)
  • References: <e4bits$1a9$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Eckhard Schlemm schrieb:
> Hello everyone,
> 
> My question is probably rather simple to answer but I just don't know how to
> do it.
> 
> I am nummerically solving a differential equation using NDSolve and then I
> want to apply a NonlinearFit on the resulting InterpolatingFunction
> object....and therefore need to have access to the data points which NDSolve
> created and from which the InterpolatingFunction is created....Is there any
> fast and direct way to get these data points ? (There must be....)
> 
> Thanks in advance
> 
> Eckhard
> 
> 
Hi Eckhard,


sol=y/.First@
       NDSolve[{y''[x]==-y[x]+y'[x]Cos[x]+Sin[3x],y[0]==0,y'[0]==0},y,{x,0,10Pi}];

xyData=Transpose[{sol[[3,1]],sol[[4,2,1+Most@sol[[4,1]]]]}];

and compare
p1=ListPlot[xyData,PlotJoined->True];
to

p2 = Plot[
     sol[x], {x, 0, 10Pi}, PlotPoints -> Length[sol[[4, 1]]] - 1, PlotStyle -> Red];

DisplayTogether[p1,p2]

Peter


  • Prev by Date: Re: Reconstructing data points from a InterpolatingFunction object
  • Next by Date: Re: compound symmetrical primes
  • Previous by thread: Re: Reconstructing data points from a InterpolatingFunction object
  • Next by thread: Re: Reconstructing data points from a InterpolatingFunction object