1 2 3 4 5 6
x=[-pi/2 0 pi/2 pi]; y=[1 0 1 0] xx=-2:.01:3.5 yy=spline(x,y,xx); plot(x,y,'k*',xx,yy) p = polyfit(x, y, 3)