+ Reply to Thread
Results 1 to 15 of 15

Distance from a point to a curve

  1. #1
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Distance from a point to a curve

    Hello, I am trying to find the minimum distance between a series of data points and a function. I know how to do it symbolically, plug the formula into the distance formula, take the derivative and set to zero to find the minimum and plug into the distance formula, but I am having a hard time figuring out how to do this in excel. One method I can think of is to calculate the distances from the point to the surrounding points on the function and take the minimum. However this would require about 40 distance per data point and I have 8000 data points. Is there a way to do this in one step, and I would prefer not to use macros. Or if you have alternate suggestions I am completely open.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Distance from a point to a curve

    Are these calculated data points for a smooth function known in closed form, or noisy measurements?

    If the former (and depending on the function), I'd write the equation for the distance and use Solver to minimize it (if you can't just solve it algebraically).
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Distance from a point to a curve

    I am comparing recorded (noisy) data to a calculated formula. The formula is a repeating piecewise function formed from lines a circles. The lines are easy enough to solve algebraically but the circles turn out to be a complex forumla due to subbing a square root into another square root and taking the derivative.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Distance from a point to a curve

    Post a workbook and explain further?

  5. #5
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Distance from a point to a curve

    I cannot upload the worksheet because it is too large with all the data. All I am trying to do is find the minimum distance between a data set and it's expected value. I need a way to compute the minimum distance between a data point and curve.
    Last edited by bjack205; 02-04-2011 at 12:51 PM.

  6. #6
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Distance from a point to a curve

    where is it

  7. #7
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Distance from a point to a curve

    I could not upload the file due to it's size.

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Distance from a point to a curve

    zip it or remove unnecessary data

  9. #9
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Distance from a point to a curve

    Okay, I trimmed it down and attached it.
    Attached Files Attached Files

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Distance from a point to a curve

    I thought one of these was a mathematical function -- those are all just numbers.

  11. #11
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,607

    Re: Distance from a point to a curve

    Would this give minimum distance between two points? =MIN(ABS(C2-$A$2:$A$722)) (comfirmed with ctrl+shift+enter)?

    And then minimum of all points is =MIN(E:E)

    That give's me 1E-5 which is probably right for points but if you threat them as lines then it should be 0 due of overlaping....

  12. #12
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Distance from a point to a curve

    I don't believe so, to my understanding that formula is simply taking the vertical difference in distance, I need the normal distance. This requires the use of derivatives.

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Distance from a point to a curve

    In E2, which MUST be confirmed with Ctrl+Shift+Enter:

    =SQRT(MIN(((D2 - $A$2:$A$722)^2 + (C2 - $B$2:$B$722)^2)))

    Copy down.

    That gives some numbers like this:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-03-2011
    Location
    Cedar Park, Texas
    MS-Off Ver
    Excel 2003
    Posts
    15

    Re: Distance from a point to a curve

    I think that will work. I am not familiar with array functions so I have a quick question, does an array function evaluate by row or evaluate every pair? In this case for instance, will the function select A1 and B2 if that corresponds to a lower value to will solely evaluate A1 and A2 etc?

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Distance from a point to a curve

    In the formula, it finds the minimum distance point in the col A/B data to D2 and C2.

    When copied down, it finds the minimum distance point to D3 and C3, D4 and C4, ...

    See http://www.cpearson.com/excel/ArrayFormulas.aspx

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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