x=-pi/2:pi/200:pi/2; y=abs(sin(x)); plot(x,y,'k-'); set(gcf,'color','white'); hold on xx=-pi/2:pi/100:pi/2; yy=abs(sin(xx)); xx1=[xx;xx;0*xx;1./(0*xx)]; xx1=(reshape(xx1,4*max(size(xx1)),1))'; yy1=[0*yy;yy;yy;1./(0*xx) ]; yy1=(reshape(yy1,4*max(size(yy1)),1))'; zzz=line(xx1,yy1); set(zzz,'color',[0.5 0.5 0.5],'linestyle',':') hold off set(gca,'ylim',[0 1.08],'xlim',[-1.65 1.65])