From bug-request at octave dot org Thu Jan 5 05:53:42 2006 Subject: interp1.m (octave-forge) *linear From: Olaf Till To: bug at octave dot org Date: Thu, 5 Jan 2006 03:04:39 -0600 This is a bug in a component of octave-forge, please forward if this is not the correct mailing list. If someone wants to respond --- I am not subscribed to bug at octave dot org dot Function: interp1.m Author: Paul Kienzle Version: Date of last change documented in the file: 2002-01-23 Description: In method '*linear' the results are different from method 'linear' (despite of even spacing of x) when the difference between neighboured x's is not equal to 1. Suggested fix: in lines 131 to 139: elseif strcmp(method, '*linear') ## find the interval containing the test point t = (xi - minx)/dx + 1; idx = floor(t); ## use the endpoints of the interval to define a line dy = [y(2:ny,:) - y(1:ny-1,:); zeros(1,nc)]; s = (t - idx)./dx; yi(range,:) = s(:,ones(1,nc)).*dy(idx,:) + y(idx,:); there is a doubled division by `dx' (in line 133 and in line 138). Changing line 138 s = (t - idx)./dx; to s = t - idx; makes method '*linear' return the same results as 'linear' even with non integer x's for me. Regards, Olaf ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------