Results 1 to 5 of 5

Linear interpolation helps

Threaded View

  1. #1
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,415

    Linear interpolation helps

    Linear interpolation is a somewhat common question that comes up on the forums, and I see a few different ways people approach it. With my recent "upgrade" to the 2024 version of Excel, I decided to make my first LAMBDA() UDF attempt to be for linear interpolation. Then I decided to post it here as a possible help for others. I don't want to claim that my approach here is the only or the best approach, so, if anyone has their own offering to make, please feel free to add it.

    The LAMBDA() function I came up with is this:
    =LAMBDA(knowny,knownx,newx,TREND(VSTACK(INDEX(knowny,XMATCH(newx,knownx,-1,2)),INDEX(knowny,XMATCH(newx,knownx,1,2))),VSTACK(INDEX(knownx,XMATCH(newx,knownx,-1,2)),INDEX(knownx,XMATCH(newx,knownx,1,2))),newx))
    I structured the function call to be basically the same as the TREND() function and Gnumeric's INTERPOLATION() function. Simply assign the function to a name in the name manager, and you have a UDF that you can call that will do linear interpolation.

    One note. As currently programmed, the function assumes that your "known_x" values are sorted in ascending order (see the optional toggles in the XMATCH() functions). It also returns an error if your newx value is outside of the range of knownx values (it only does interpolation, it won't do extrapolation).

    Usage is illustrated in the attached file. I've also included the old strategy for interpolation that I have recommended over the years.

    Hopefully it is helpful for others. Feel free to add your strategies for linear interpolation to give users different options.
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

Thread Information

Users Browsing this Thread

There are currently 4 users browsing this thread. (0 members and 4 guests)

Similar Threads

  1. Linear Interpolation
    By cl6120 in forum Excel General
    Replies: 4
    Last Post: 07-10-2020, 12:20 AM
  2. Interpolation, non linear. Need help please.
    By traumerei1838 in forum Excel General
    Replies: 8
    Last Post: 08-12-2015, 01:04 AM
  3. [SOLVED] how to do linear interpolation
    By fight2 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-11-2015, 08:40 PM
  4. Linear Interpolation help
    By jsuarez199 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-21-2013, 03:12 PM
  5. Linear Interpolation
    By mikethemonster in forum Excel General
    Replies: 0
    Last Post: 07-04-2011, 02:27 PM
  6. VBA Linear Interpolation
    By WAW in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-25-2010, 04:55 PM
  7. Linear Interpolation
    By Metalmaniac in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-03-2005, 10:05 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1