bugGNU Octave - Bugs: bug #60967, interp1 returns wrong result when...


bug #60967: interp1 returns wrong result when given both a method and an extrapval

Submitter:  Hartmut <hardy>
Submitted:  Sun 25 Jul 2021 03:45:15 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.3.0 Operating System:  * Any
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


Mon 26 Jul 2021 04:06:26 PM UTC, comment #3: 

Thank you for testing.
Glad I could help.

Closing report as fixed.

Markus Mützel <mmuetzel>
Project Member
Mon 26 Jul 2021 02:58:38 PM UTC, comment #2: 

Wow, that was a fast fix, thank you Markus!

I have tested interp1.m from the Octave repo (stable branch) including  the patch from comment #1. My "problem code" from comment #0 now works just fine, fully as expected. Also some other small testing worked fine. And all BIST tests from interp1 still pass on my PC.

So my conclusion would be: This bug is FIXED.

I will probably use the proposed workaround from comment #1 to go on with fixing bug 60946, that way the image package can stay fully compatible to several older versions of core Octave.

Hartmut <hardy>
Sun 25 Jul 2021 06:29:35 PM UTC, comment #1: 

I pushed a change to the stable branch that should be fixing this issue here:

For the time being, you could work around this by calling `interp1` with an explicit argument `x`. E.g.:

result1 = interp1(1:2, [10, 6], [1, 1.5, 2], 'cubic')
result2 = interp1(1:2, [10, 6], [1, 1.5, 2], 'cubic', 0)

Markus Mützel <mmuetzel>
Project Member
Sun 25 Jul 2021 03:45:15 PM UTC, original submission:  

I have observed this in Octave 6.3.0 (when trying to fix bug #60946).

When running the following code in Octave, I get an interpolation result that I consider wrong in itself, and also not Matlab compatible:

result1 = interp1( [10, 6], [1, 1.5, 2], 'cubic')
result1_matlab = [10, 8, 6]  % -> works fine in Octave as well

result2 = interp1( [10, 6], [1, 1.5, 2], 'cubic', 0)
result2_matlab = [10, 8, 6] %  -> gives NA in Octcave, why ???

I am trying to get a "cubic" interpolation (but any solution should work for arbitrary interp methods) but also specify an extrapval value.

Is there an easy way to fix this in core Octave (or even a useful workaround) so that I can go on with fixing bug #60946?

Hartmut <hardy>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by hardy (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 project members can vote.





    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-07-26 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-07-25 mmuetzel StatusNone Ready For Test

    Back to the top

    Powered by Savane 3.9