I think this is what you really want to do:
x=[1 2.5 2 3 5 6 3.5 2.1 4 .5];
[x, inds] = sort(x);
y=[1 3 1.5 2 1.4 5 3.8 2.1 3 3.5];
y = y(inds);
p=plot(x,y,'r.');
set(p,'MarkerSize',30)
set(gca,'XLim',[0 10])
reg=polyfit(x,y,2);
hold on
plot(x, polyval(reg, x))