## bug #38917: interp1 gives inconsistent results

 Submitted by: None Submitted on: Tue 07 May 2013 05:17:57 AM UTC Category: Libraries Severity: 3 - Normal Priority: 5 - Normal Item Group: Inaccurate Result Status: Fixed Assigned to: None Originator Name: Ted12201 Originator Email: -unavailable- Open/Closed: Closed Release: 3.6.4 Operating System: Any

Add a New Comment (Rich Markup):

## You are not logged in

Wed 19 Jun 2013 07:13:56 PM UTC, comment #1:

Happily, this has already been fixed in the development code. To access the fix you will need to build from development sources or wait until the next major release of Octave (3.8).

Rik <rik5>
Tue 07 May 2013 05:17:57 AM UTC, original submission:

interp1(x,y,z) returns different results from MatLab and SciLab when both y and z are matrices. It appears that MatLab and SciLab results are correct.

For example,

x=1:30;
y=[x.^2; x.^0.5];
z=2:5;
X=X';
y=y';
z=z';
z=[z.^2 z.^0.5];
interp1(x,y,z)
interp1(x,y,z(:,1))
interp1(x,y,z(:,2))

Both Matlab and Scilab return

ans(:,:,1) =
16.0000 2.2426
81.0000 3.1962
256.0000 4.0000
625.0000 5.1803

ans(:,:,2) =
2.0000 1.1716
3.0000 1.3032
4.0000 1.4142
5.0000 1.4892

ans =
16 2
81 3
256 4
625 5

ans =
2.2426 1.1716
3.1962 1.3032
4.0000 1.4142
5.1803 1.4892

But Octave returns

ans(:,:,1) =
16.0000 2.2426
81.0000 1.0000
256.0000 6.0711
625.0000 4.0000

ans(:,:,2) =
2.0000 1.3032
3.0000 1.0978
4.0000 1.6469
5.0000 1.4892

ans =
16 2
81 3
256 4
625 5

ans =
2.2426 1.1716
3.1962 1.3032
4.0000 1.4142
5.1803 1.4892

These results suggest Octave is calculating correctly when a vector is given as z but not when it is a matrix.

Anonymous

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

Attach File(s):

Comment:

No files currently attached

Depends on the following items: None found

Items that depend on this one: None found

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

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.

Please enter the title of George Orwell's famous dystopian book (it's a date):