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