From octave-sources-request at bevo dot che dot wisc dot edu Tue Aug 29 11:12:25 2000 Subject: Re: Patch to spline.m in matcompat package From: Paul Kienzle To: trond at varslot dot net Cc: octave-sources at bevo dot che dot wisc dot edu Date: Tue, 29 Aug 2000 17:12:38 +0100 Thanks! The following also fixes the problem: 76,79c76,79 < a = (x(idx+1) - xnew) ./ h(idx); < b = (xnew - x(idx)) ./ h(idx); < a2 = (a.^3 - a) .* h(idx).^2/6; < b2 = (b.^3 - b) .* h(idx).^2/6; --- > a = (x(idx+1) - xnew) ./ h; > b = (xnew - x(idx)) ./ h; > a2 = (a.^3 - a) .* h.^2/6; > b2 = (b.^3 - b) .* h.^2/6; Note that calling spline once for each table lookup is very slow since it needs to recompute the whole spline each time. Better would be to collect all the points which you want to look up and call spline only once. If this is not possible, then you should recode spline so that it returns a piece-wise polynomial, and use ppval to evaluate the table entries. This will make it more compatible with Matlab's spline function as well. The algorithm that Zdenek Remes used combines building and evaluating, so the whole function will need to be recoded to do this. Paul Kienzle pkienzle at kienzle dot powernet dot co dot uk >From trond at varslot dot net Tue Aug 29 14:57:52 2000 > >Hello, > >You have compiled an extensive package of compatibility functions. I use >it a lot, and fint it very useful. > >I when I tried to use the function spline, however, it did not seem to >react very well to computing the value of a function in only 1 point (not >in only a few even. You might try this out: > >x = 0:10; y = sin(x);xspline = 5.5; yspline = spline(x,y,xspline) > >This is useful when computing a function based on tabular values. I >bellieve the following patch to spline.m should solve the problem, though >you might >have a more elegant solution: > > >75c75,76 >< h = x(idx+1) - x(idx); >--- >> h=x; >> h(idx) = x(idx+1) - x(idx); > > > >Yours sincerely >Trond Varslot > > > ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------