octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should interp1.m function allow jumps in X-values?


From: Michael D Godfrey
Subject: Re: Should interp1.m function allow jumps in X-values?
Date: Wed, 22 Aug 2012 09:29:18 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0

On 08/22/2012 08:33 AM, Ben Abbott wrote:
The reason for the difference is subtle (and sorry for not pointing it out earlier).  The sort() function does not change the order of the duplicate X values.  Thus, the continuity condition is not switched from right to left.  The flipup() function is used in interp1 to do that.  Below I used the fliplr() to ensure the proper continuity.

	X = [ 2 1 3 2];
	Y = [ 9 1 3 10]; 
	% These are right-continuos (returns 10)
	y1 = interp1 (X, Y, 2)
	[~, n] = sort (X);
	y2 = interp1 (X(n), Y(n), 2)
	[~, n] = sort (X, "descend");
	y3 = interp1 (X(n), Y(n), 2)
	y4 = interp1 (X, Y, 2, "-right")
	% These are left-continuous (returns 9)
	[~, n] = sort (fliplr (X), "descend");
	y5 = interp1 (X(n), fliplr(Y)(n), 2)
	y6 = interp1 (X, Y, 2, "-left")

Ben
Very good.  I could have thought of that!  So, that gets rid of an important
problem.  And this adds a bit in favor of your addition of -right and -left,
or at least another point to be made clear in the documentation.  This
is definitely a subtle point about sorting.  Time to look up what Knuth
has to say about this.

By the way, the current devel interp1.m does not do the flipr().  Did you
add that in your local patch?

Michael
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]