changeset 18415:b06675ef40f2 stable

interp1.m: Fix handling multi-column y-input with jumps (bug #40825). * interp1.m: Eliminate jumps from both x AND y before doing linear interpolation.
author Juan Pablo Carbajal <ajuanpi+dev@gmail.com>
date Fri, 06 Dec 2013 15:08:41 +0100
parents 0f32b34f6ec0
children 71d1a1450365
files scripts/general/interp1.m
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/interp1.m	Wed Jan 29 21:26:13 2014 +0100
+++ b/scripts/general/interp1.m	Fri Dec 06 15:08:41 2013 +0100
@@ -237,18 +237,23 @@
         yi = ppval (pp, reshape (xi, szx));
       endif
     case "linear"
-      dy = diff (y);
-      dx = diff (x);
-      dx = repmat (dx, [1 size(dy)(2:end)]);
-      coefs = [(dy./dx).'(:), y(1:nx-1, :).'(:)];
+
       xx = x;
-
+      yy = y;
+      nxx = nx;
       if (have_jumps)
         ## Omit zero-size intervals.
-        coefs(jumps, :) = [];
+        yy(jumps, :) = [];
         xx(jumps) = [];
+        nxx = rows (xx);
       endif
 
+      dy = diff (yy);
+      dx = diff (xx);
+      dx = repmat (dx, [1 size(dy)(2:end)]);
+
+      coefs = [(dy./dx).'(:), yy(1:nxx-1, :).'(:)];
+
       pp = mkpp (xx, coefs, szy(2:end));
       pp.orient = "first";