help-octave
[Top][All Lists]
Advanced

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

Table lookup & interpolation


From: Luke Scharf
Subject: Table lookup & interpolation
Date: 18 Mar 2003 21:42:43 -0500

I've implemented a function as a table lookup.  It would be nice if it
could interpolate between the values as well.  Any ideas?

Here is what I'm using now.  It works -- except no interpolation:
------------------- Begin Code Snippet -------------------
% p(h) - pressure as a function of altitude
function a = p_helper(h)
        switch (h(:))
                case (0)        a = 2116.2;
                case (1000)     a = 2040.9;
                case (2000)     a = 1967.7;
                case (3000)     a = 1896.7;
                case (4000)     a = 1827.7;
                case (5000)     a = 1760.8;
                case (6000)     a = 1696.0;
                case (7000)     a = 1633.0;
                case (8000)     a = 1571.9;
                case (9000)     a = 1512.9;
                case (10000)    a = 1455.4;
                case (11000)    a = 1399.8;
                case (12000)    a = 1345.9;
                case (13000)    a = 1293.7;
                case (14000)    a = 1243.2;
                case (15000)    a = 1194.3;
                case (16000)    a = 1147.0;
                case (17000)    a = 1101.1;
                case (18000)    a = 1056.9;
                case (19000)    a = 1014.0;
                case (20000)    a = 972.6;
                case (21000)    a = 932.5;
                case (22000)    a = 893.8;
                case (23000)    a = 856.4;
                case (24000)    a = 820.3;
                case (25000)    a = 785.3;
                case (26000)    a = 751.7;
                case (27000)    a = 719.2;
                case (28000)    a = 687.9;
                case (29000)    a = 657.6;
                case (30000)    a = 628.5;
                otherwise       a = -1;
        endswitch
endfunction
function a = p(h)
        count = 1;
        for i(:) = h
                a(count) = p_helper(i);
                count = count+1;
        endfor
endfunction
------------------- End Code Snippet -------------------


If there a Right Way to do this?


Thanks in advance,
-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]