X = -2:2;  Y = [1 0 1 0 1];
P = lagrangepoly(X,Y);
xx = -2:.01:2;
plot(xx,polyval(P,xx),X,Y,'or');
grid;