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: Ted Harding
Subject: RE: Table lookup & interpolation [follow-up]
Date: Wed, 19 Mar 2003 09:34:11 -0000 (GMT)

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

Now the agreement between p(h) and phat(h) is very close indeed.

    p(h)   phat(h)
  2040.90  2040.85
  1967.70  1967.75
  1896.70  1896.65
  1827.70  1827.68
  1760.80  1760.89
  1696.00  1695.96
  1633.00  1632.91
  1571.90  1572.09
  1512.90  1512.76
  1455.40  1455.45
  1399.80  1399.79
  1345.90  1345.89
  1293.70  1293.72
  1243.20  1243.19
  1194.30  1194.36
  1147.00  1146.89
  1101.10  1101.22
  1056.90  1056.82
  1014.00  1014.06
   972.60   972.56
   932.50   932.52
   893.80   893.79
   856.40   856.46
   820.30   820.19
   785.30   785.39
   751.70   751.66
   719.20   719.26
   687.90   687.82

Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 19-Mar-03                                       Time: 09:34:11
------------------------------ XFMail ------------------------------



-------------------------------------------------------------
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]