MathGroup Archive 2009

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

Search the Archive

Re: Linear Interpolation problems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg102374] Re: [mg102359] Linear Interpolation problems
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Fri, 7 Aug 2009 05:30:08 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

ndp = 2; (* number of decimal places *)

f = Interpolation[{{3, 20}, {10, 50}},
   InterpolationOrder -> 1];

Table[{n, NumberForm[f[n] // N, {4, ndp}]},
 {n, 3, 10}]

{{3, "20.00"}, {4, "24.29"}, {5, "28.57"}, {6, "32.86"}, 
   {7, "37.14"}, {8, "41.43"}, {9, "45.71"}, {10, "50.00"}}

f = Interpolation[{
    {{1, 3}, 20}, {{2, 3}, 30}, {{3, 3}, 60},
    {{1, 10}, 50}, {{2, 10}, 55}, {{3, 10}, 25}},
   InterpolationOrder -> 1];

m = Table[NumberForm[f[firm, year] // N, {4, ndp}],
  {firm, 3}, {year, 3, 10}]

{{"20.00", "24.29", "28.57", "32.86", "37.14", "41.43", 
     "45.71", "50.00"}, {"30.00", "33.57", "37.14", 
     "40.71", "44.29", "47.86", "51.43", "55.00"}, 
   {"60.00", "55.00", "50.00", "45.00", "40.00", "35.00", 
     "30.00", "25.00"}}

TableForm[m, TableHeadings ->
  {{"A", "B", "C"}, Range[3, 10]}]


Bob Hanlon

---- kosal lee <leekosal at yahoo.com> wrote: 

=============
Hello,

I am new to Mathematica. Please help me with linear interpolation problems. Thank you for your help. 

First, suppose I have two real values 

year               earnings
x = 3              f(x) =   20
x= 10             f(x) =   50

I want to have the interpolated values of f(4), f(5), to f(9) which is between actual values of f(3) and f(10). How can I do that with Mathematica?


Second, suppose I have an excel spreadsheet having those above values for multiples firms as of the following

firm      f(3)       f(10)
A          20        50
B          30        55
C          60        25

I want to have the values of f(4) till f(9) as above and are stored in excel spreadsheet as of the following:

firm      f(3)     f(4)    f(5)  ...    (f9)      f(10)
A          20                                            50
B          30                                            55
C          60                                            25  


Best Regards,
Kosal




  • Prev by Date: Radio buttons panel
  • Next by Date: Re: Finding positive / non-complex solutions (newbie)
  • Previous by thread: Re: Linear Interpolation problems
  • Next by thread: Re: Linear Interpolation problems