MATLAB: When does ‘interp1’ function give ‘The grid vector must contain unique points’ error

interp1MATLAB

When does 'interp1' function give 'The grid vector must contain unique points' error?

Best Answer

This error comes when there are duplicate points in input to 'interp1'.
You can remove duplicates using 'unique' function.
Example:-
>> [x, index] = unique(x);
>> yi = interp1(x, y(index), xi);