x=[-4:0.01: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;
%hold off;
%plot(x,y,'black','LineWidth',1);
for i=1:n
  y(i)=4*(sin(x(i))+sin(3*x(i))/3)/pi;
end;
%hold on;
plot(x,y,'black');
axis([-4 4 -1.5 1.5]);
axis on;
