Path: news.mathworks.com!not-for-mail From: "John D'Errico" <woodchips@rochester.rr.com> Newsgroups: comp.soft-sys.matlab Subject: Re: distance between two points along a curve Date: Sat, 8 May 2010 13:04:05 +0000 (UTC) Organization: John D'Errico (1-3LEW5R) Lines: 33 Message-ID: <hs3ng5$g6u$1@fred.mathworks.com> References: <hs3e0d$cht$1@fred.mathworks.com> <hs3f5t$qh4$1@fred.mathworks.com> <hs3g9h$7u4$1@fred.mathworks.com> <hs3iir$49g$1@fred.mathworks.com> Reply-To: "John D'Errico" <woodchips@rochester.rr.com> NNTP-Posting-Host: webapp-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1273323845 16606 172.30.248.38 (8 May 2010 13:04:05 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 8 May 2010 13:04:05 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 869215 Xref: news.mathworks.com comp.soft-sys.matlab:633740 "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hs3iir$49g$1@fred.mathworks.com>... > "Luca Turchet" <tur@imi.aau.dk> wrote in message <hs3g9h$7u4$1@fred.mathworks.com>... > > Dear Bruno, > > thanks a lot. > > > > The problem is that I need to calculate the x,y coordinates of the point which is at a given distance from another point along the curve. > > > > LetÂ´s say A = (x1, f(x1)) where f = normal distribution > > I need to find B = (x2, f(x2)) such that the distance between A and B is equal to a specified value, for example 2. > > > > Do you have any idea how to do this? > - - - - - - - - - > As a suggestion, use the function 'cumtrapz' with the integrals suggested by Bruno and Torsten with sufficiently close spacing of points starting at point A to give the accuracy you need with trapezoidal integration. Then your task is to locate within the 'cumtrapz' vector result, that value that first exceeds the desired distance. The 'find' function with an inequality can help you do this. Then in the last interval you can make an appropriate linear adjustment to locate the point B within it accurately. > > This might be less time consuming than using 'fzero' which would require numerous repeated integrations all starting back at point A. > > Roger Stafford Another option is to use ode45. It can integrate the arclength term. Then set it so that it finds the specific arclength that you need. This is actually the best way to solve the problem. For more details, look at my arclength and interparc codes on the file exchange. interparc does a spline arclength integral. Alternatively, you could just sample the Gaussian curve and then call one of these codes. Of course, since this is surely for homework, neither alternative is probably an option. John