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.
|