x=[-4:0.05:4];
n=size(x,2);
y=zeros(n,1);
for i=1:n
  if (x(i)<=-pi)|((x(i)>0)&(x(i)<=pi))
    y(i)=1;
  else
    y(i)=-1;
  end;
end;
plot(x,y,'black');
axis([-4 4 -1.5 1.5]);
axis on;