Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: distance between two points along a curve
Date: Sat, 8 May 2010 21:33:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 30
Message-ID: <hs4lah$756$1@fred.mathworks.com>
References: <hs3e0d$cht$1@fred.mathworks.com> <hs3f5t$qh4$1@fred.mathworks.com> <hs3g9h$7u4$1@fred.mathworks.com> <hs3hs7$ika$1@fred.mathworks.com> <hs3ikh$7g9$1@fred.mathworks.com> <hs3jtp$sso$1@fred.mathworks.com> <hs3lej$6jj$1@fred.mathworks.com> <hs42df$eo0$1@fred.mathworks.com> <hs4eog$dhh$1@fred.mathworks.com> <hs4g1p$5jm$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1273354385 7334 172.30.248.35 (8 May 2010 21:33:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 8 May 2010 21:33:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:633826

"Luca Turchet" <tur@imi.aau.dk> wrote in message <hs4g1p$5jm$1@fred.mathworks.com>...
> Dear Roger,
> thanks a lot.
> I tried to understand how that functions proposed by John work, but I was not successiful in applying them for my purposes ;-(
> I would like to have just an example of the code to use, in order to understand how I can use those functions in my case.
> 
> For that reason I opted for the solution you proposed. BTW, I implemented it well?
> It is correct?
> 
> It is for sure my fault if I have not understood fully how those functions work. I will look at them better now, and I hope to find a solution as soon as possible.
> 
> Any suggestion or code example is really appreciated ;-)
> 
> Luca
> 
> P.S. @John: I forgot to tell you "thanks" for the precious advice.

  Bruno gave you a good hint as to why your 'find' might come up empty when he said "especially when the function has a large slope".  Since you have asked me if your code is correct, perhaps he will forgive me if I spill the beans.  The problem is that in the inequalities

 Z>distance & Z < distance + step_increment

you might easily be so unlucky that all Z's are either less than "distance" or greater than "distance+step_increment", since they have larger increments than "step_increment", especially if the slope is still high.  Instead of the double inequality, you should be using 'find' with the 'first' option and just your first inequality.

  Also you need to be sure and select the upper end of the X vector so that it exceeds A_x by at least as much as the quantity "distance" to ensure that a sufficiently large Z will attained.  Right now you just have a 15.  It should be A_x+distance.

  One last point.  The B_x you have selected gives an arc length beyond the desired distance, and you need to adjust it backwards appropriately.  That is, B_x needs to be reduced back towards the previous X value in proportion to the amount back toward the previous Z value of the desired "distance" value.

  Well, one last, last point.  By all means use John's 'ode45' method.  It is by far the cleanest of all the ideas that have been put forth here.  Don't use mine.  It was thought up on the spur of the moment.

Roger Stafford