MATLAB: Interpolate non-monotonic test data

datainterpolationnon-monotonic

Hello all,
I want to interpolate at specific values the curve in the picture attached (say every 0.01 in the x axis). Any idea how? The test data consists of a huge number of data points, so I want to clean them a bit.
Thanks

Best Answer

What I did was to run through all the data for the amount of times I wanted and interpolated when the point of interest was between the data. The code I used was:
k=1;
lo=50;
ul=49;
i=k;
j=1;
i=1;
for j = 1:lo
x1=0;
x2(j,1)=j/100;
while x2(j,1)>=x1
x1=A(i,1);
x3=A(i+1,1);
y1=A(i,2);
y3=A(i+1,2);
if x2(j,1)<x3
B(j,1)=j/100;
B(j,2)=(x2(j,1)-x1)*(y3-y1)/(x3-x1)+y1;
y2(j,1) = B(j,2);
end
i=i+1;
end
end
k=i;
l=length(x2);
j=1;
for j = 1:ul
x1=lo/100;
x2(j+l,1)=lo/100-j/100;
while x2(j+l,1)<=x1
x1=A(k,1);
x3=A(k+1,1);
y1=A(k,2);
y3=A(k+1,2);
if x2(j+l,1)>x3
B(j+l,1)=lo/100-j/100;
B(j+l,2)=(x2(j+l,1)-x1)*(y3-y1)/(x3-x1)+y1;
y2(j+l,1) = B(j+l,2);
end
k=k+1;
end
end
etc... for as many cycles I wanted it. It worked well.
Related Question