MATLAB: 1D interpolation with non-monotonic scattered data

1dinterpolationscattered data non-monotonic

I cant figure out how do 1D interpolation with scattered data. I know how to get it working with 2D interpolation, but scatteredinterpolant only works with 2D or more. Thank you for your help!

Best Answer

small example:
x = rand(30,2); % you data
x1 = sortrows(x,1);
F = griddedInterpolant(x1(:,1),x1(:,2));
out = F(xinput);