MATLAB: Interp1 function gives an error ”Error using griddedInterpolant The grid vectors must contain unique points.”

interpolation

Size of z_Sd is (200×2) and I am trying to find the corresponding Sd value for a given value say, 0.3157 .
vq1=interp1(z_Sd(:,1),z_Sd(:,2),0.3157);
However I am getting this error. Help me out

Best Answer

[x,~,J] = unique(z_Sd(:,1));
y = accumarray(J, z_Sd(:,2), [], @mean);
vq1 = interp1(x,y,0.3157);