help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Table lookup & interpolation [follow-up]


From: Luke Scharf
Subject: RE: Table lookup & interpolation [follow-up]
Date: 20 Mar 2003 09:15:30 -0500

On Wed, 2003-03-19 at 04:34, Ted Harding wrote:
> On 19-Mar-03 Ted Harding wrote:
> > For this case, log(p(h)) is quite close to a linear function of h
> > (there is slight curvature). Possibly, linear interpolation of
> > log(p) between points may be adequate. If not, quadratic interpolation
> > using three consecutive points almost certainly is adequate.
> 
> I just checked: using quadratic interpolation of log(p), the
> following compares p(h) with phat(h) where the points used for
> interpolation are (h-1000,p(h-1000)), (h+1000,p(h+1000)),
> (h+2000,p(h+2000)). The octave commands were:
> 
> y=log(p);c=[];
> for i=2:29,
> x=h(i);
> h1=h(i-1);h2=h(i+1);h3=h(i+2);
> y1=y(i-1);y2=y(i+1);y3=y(i+2);
> phat=exp((x-h2)*(x-h3)*y1/((h1-h2)*(h1-h3))+ ...
>          (x-h1)*(x-h3)*y2/((h2-h1)*(h2-h3))+ ...
>          (x-h1)*(x-h2)*y3/((h3-h1)*(h3-h2)));
> c=[c;[p(i) phat]];endfor;c

I'll give this a try when I get home from work this evening!

Thanks again!

-Luke



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]