octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #38445] interp1 with pchip or spline options o


From: anonymous
Subject: [Octave-bug-tracker] [bug #38445] interp1 with pchip or spline options outputs column vector intead of row vector
Date: Thu, 28 Feb 2013 20:32:09 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20100101 Firefox/16.0

URL:
  <http://savannah.gnu.org/bugs/?38445>

                 Summary: interp1 with pchip or spline options outputs column
vector intead of row vector
                 Project: GNU Octave
            Submitted by: None
            Submitted on: Thu 28 Feb 2013 08:32:07 PM UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: Gyorgy Hexner
        Originator Email: address@hidden
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.6.3
        Operating System: GNU/Linux

    _______________________________________________________

Details:

+verbatim
##
##interp1 error demo
##

x=0:0.1:2;
y=[sin(x); cos(x)]';

##call to interp1 reults in a row vector
z = interp1(x, y, 0.5)

##but a call with the option pchip results in a column vector
zp = interp1(x, y, 0.5, 'pchip')
-verbatim

problem is easily corrected by adding transpose .' operation when using pchip
or spline options

--- /usr/share/octave/3.6.3/m/general/interp1.m 2012-12-01 21:46:44.000000000
+0200
+++ interp1.m   2013-02-28 19:57:56.075784320 +0200
@@ -247,10 +247,10 @@
 
     if (ispp)
       y = shiftdim (reshape (y, szy), 1);
-      yi = pchip (x, y);
+      yi = pchip (x, y).';
     else
       y = shiftdim (y, 1);
-      yi = pchip (x, y, reshape (xi, szx));
+      yi = pchip (x, y, reshape (xi, szx)).';
     endif
   case {"spline", "*spline"}
     if (nx == 2 || starmethod)
@@ -259,10 +259,10 @@
 
     if (ispp)
       y = shiftdim (reshape (y, szy), 1);
-      yi = spline (x, y);
+      yi = spline (x, y).';
     else
       y = shiftdim (y, 1);
-      yi = spline (x, y, reshape (xi, szx));
+      yi = spline (x, y, reshape (xi, szx)).';
     endif
   otherwise
     error ("interp1: invalid method '%s'", method);





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?38445>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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