bugGNU Octave - Bugs: bug #51030, interp1 linear returns...

 
 

bug #51030: interp1 linear returns inconsistent results for all but first values in matrix

Submitter:  None
Submitted:  Mon 15 May 2017 05:40:54 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Niklas Hambuechen Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.2.1
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 18 May 2017 03:17:36 PM UTC, comment #3: 

I pushed the patch to the stable branch of Octave here (http://hg.savannah.gnu.org/hgweb/octave/rev/22fd2ad85218).  This will be a part of the bug fix release 4.2.2 if such a release occurs.  Otherwise, it will be a part of the next major release 4.4.0.  However, you can continue to just use the attached interp1.m as a workaround in a local installation.  Closing report.

Rik <rik5>
Group administrator
Mon 15 May 2017 11:03:18 PM UTC, comment #2: 

Attached is both a patch, and the full interp1.m file.  It can be tested by simply swapping in the new interp1.m file for the old one.

Rik <rik5>
Group administrator
Mon 15 May 2017 09:18:37 PM UTC, comment #1: 

Confirmed.  And it is still present on the current stable version of Octave which is 4.2.1.

Rik <rik5>
Group administrator
Mon 15 May 2017 05:40:54 PM UTC, original submission:  

When running the following commands:

X = [120 60 0]'

v0 = [
  [ 5.4410e+03   4.8674e+03   5.1208e+03   1.2981e+04   1.2407e+04   1.2661e+04   1.8651e+04   1.8077e+04   1.8331e+04]
  [ 4.0110e+03   3.6304e+03   3.8449e+03   1.0423e+04   1.0043e+04   1.0257e+04   1.5951e+04   1.5570e+04   1.5785e+04]
  [-3.0221e+02  -1.4564e+01   0.0000e+00  -3.0221e+02  -1.4564e+01   0.0000e+00  -3.0221e+02  -1.4564e+01   0.0000e+00]
]

x1 = -3.1623

interp1(X,v0,x1,'linear')

Octave 4.0.0 returns:

ans =

 Columns 1 through 6:

        NA   -206.67   -202.65   -867.48   -544.65   -540.60

 Columns 7 through 9:

  -1158.84   -835.95   -831.95


Only the first value is NA, when they should all be NA.

When I run the same values (the first 2 columns) manually, they both return NA as expected:


interp1([120 60 0], [5.4410e+03 4.0110e+03 -3.0221e+02], -3.1623, 'linear')

ans = NA

interp1([120 60 0], [4.8674e+03 3.6304e+03 -1.4564e+01], -3.1623, 'linear')

ans = NA

Matlab returns the correct results as well:

>> X = [120 60 0]';
>> v0 = [

[ 5.4410e+03   4.8674e+03   5.1208e+03   1.2981e+04   1.2407e+04   1.2661e+04   1.8651e+04   1.8077e+04   1.8331e+04]
[ 4.0110e+03   3.6304e+03   3.8449e+03   1.0423e+04   1.0043e+04   1.0257e+04   1.5951e+04   1.5570e+04   1.5785e+04]
[-3.0221e+02  -1.4564e+01   0.0000e+00  -3.0221e+02  -1.4564e+01   0.0000e+00  -3.0221e+02  -1.4564e+01   0.0000e+00]
];

>> x1 = -3.1623;
>> interp1(X,v0,x1,'linear')


ans =

   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN   NaN

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #40700:  interp1.cset added by rik5 (1KiB - application/octet-stream)
file #40701:  interp1.m added by rik5 (29KiB - text/x-matlab)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-05-18 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2017-05-15 rik5 Attached File- Added interp1.cset, #40700
        Attached File- Added interp1.m, #40701
    2017-05-15 rik5 StatusConfirmed Patch Submitted
    2017-05-15 rik5 StatusNone Confirmed
        Release4.0.0 4.2.1

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code