MATLAB: Interp1: The grid vectors are not strictly monotonic increasing

interp1interpolation

In matlab I have a set of points
x = [53, 125, 179, 193, 158, 121, 115, 120, 150, 193, 246, 301, 352, 380, 385, 376, 334, 295, 298, 312, 354, 423];
y = [120, 198, 296, 392, 496, 596, 700, 743, 800, 838, 853, 839, 801, 752, 698, 599, 502, 401, 346, 301, 202, 120];
and I want to draw a spline through them all creating a sort of bulb shape. However when I attempt to simply use the command y1 = interp1(x,y,x1,'spline') I recieve the error
Error using griddedInterpolant
The grid vectors are not strictly monotonic increasing.
Error in interp1 (line 186)
F = griddedInterpolant(X,V,method);
Could someone please explain both what this error means and how I would go about fixing it? I've read in a few other posts that I should try to find a set a parametric equations that I could use to replace the vectors, but I don't really understand what that would mean practically either. This is what the points look like:
Edit: People have suggested sorting the x and y data and then drawing a spline through the sorted data. Unfortunately this produces the exact same error, and even if it were do work I believe it would simply create a series of zig-zags(like a wonky sin curve) instead of the bulb shape I need.

Best Answer

I've read in a few other posts that I should try to find a set a parametric equations that I could use to replace the vectors
I somewhat agree with that advice,
n=numel(x);
xfun=@(p) spline(1:n,x,p); %parametric functions
yfun=@(p) spline(1:n,y,p);
t=linspace(1,n,1000);
plot(x,y,'o',xfun(t),yfun(t),'.')