Hi,
We want to port a Matlab code to Octave but where it uses the interp2
function with the 'cubic' flag we get the following diference. Any
idea why this happens?
Andres Sepulveda
University of Concepcion, CHILE
clear;
close all;
clc;
if exist('OCTAVE_VERSION')
sufix = 'octave';
else
sufix = 'matlab';
end
% original data --> {x,y,data}
[x,y] = meshgrid(1:11,1:3);
data = [0.41 0.40 0.73 0.77 0.48 0.11 0.74 0.06 0.57 0.83 0.46; ...
0.98 0.32 0.54 0.38 0.19 0.30 0.33 0.03 0.68 0.07 0.44; ...
0.69 0.98 0.16 0.95 0.67 0.25 0.35 0.50 0.40 0.46 0.63];
% interpolated data --> {lon,lat,rr_}
lon = linspace(x(1),x(end),25);
lat = linspace(y(1),y(end),25);
rr1 = interp2(x,y,data,lon,lat,'linear'); % linear
rr2 = interp2(x,y,data,lon,lat,'cubic'); % cubic
% plot result
figure;
plot(rr1,'linewidth',2);
axis([1 25 0 1]);
title(['linear interpolation ',sufix]);
print(['linear_',sufix,'.eps'],'-depsc');
figure;
plot(rr2,'linewidth',2);
axis([1 25 0 1]);
title(['cubic interpolation ',sufix]);
print(['cubic_',sufix,'.eps'],'-depsc');