Re: Linear interpolation between two points found using a lookup funct

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



On Tue, 29 Nov 2005 12:31:09 -0800, aj4444 <aj4444@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

>I need to interpolate two points (x0,y0) & (x1,y1) to find the y value for a
>given x. First, I need to find x0 and x1 from a column using a lookup
>function. The x's column increases as you go down.
>
>For example given a data set:
>
>x's y's
>20.33 5
>22.69 7
>25.06 8
>27.42 18
>29.79 37
>
>Say I want to find y for x=23. I want to lookup the two closest values of
>x's that x=23 is between(22.69 and 25.06) and then use these two points to
>linearly interpolate the y for x=23. Any suggestions?
>

=IF(NewX=MAX(x_s),MAX(y_s),VLOOKUP(NewX,tbl,2)+
(INDEX(tbl,MATCH(VLOOKUP(NewX,tbl,1),x_s)+2,2)-
VLOOKUP(NewX,tbl,2))*(NewX-VLOOKUP(NewX,tbl,1))
/(INDEX(tbl,MATCH(VLOOKUP(NewX,tbl,1),x_s)+2,1)-
VLOOKUP(NewX,tbl,1)))

If your data is in A1:B6, then:

tbl =Sheet1!$A$1:$B$6
x_s =Sheet1!$A$2:$A$6
y_s =Sheet1!$B$2:$B$6


NewX can be any cell.

Errors will be output if NewX is outside of the range of x_s.


--ron
.



Relevant Pages

  • LOCATE vs. LOOKUP
    ... areas where I have a data set in a data module and use it to lookup ... using Locate to do the job that Lookup does. ... Would rather not switch all these ...
    (borland.public.delphi.database.ado)
  • Re: LOCATE vs. LOOKUP
    ... Keith G Hicks wrote: ... > For example in areas where I have a data set in a data module and use ... > it to lookup information sometimes. ...
    (borland.public.delphi.database.ado)
  • Lookup to return multiple results in one cell
    ... Above is my example data set. ... results on one line based off a lookup. ... I look for Jack and the formula returns: "X123, X224" in one cell. ...
    (microsoft.public.excel.programming)
  • Re: adapting the findnext function
    ... > in via a lookup, is there anyway to make excel think they are just there ... > chrisrowe_cr's Profile: ... Prev by Date: ...
    (microsoft.public.excel.programming)
  • Re: IF/WHEN forumla fo when a cell is between two numbers
    ... One way is to just reverse your scrip: ... Another method, which is more flexible, is to use a lookup table. ... can, if necessary, expand the formula to include many levels of conditions. ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)