rec[x_] := UnitStep[x + 1]*UnitStep[-x + 1]

recplot = Plot[rec[x], {x, -2, 2}, PlotRange->{0, 1.5}]

hann[x_] := Piecewise[{{0, x<-1}, {0.5*(1 - Cos[Pi*(x+1)]), -1<x<1}, {0, x>1}}]

hannplot = Plot[hann[x], {x, -2, 2}, PlotRange->{0, 1.5}]

Export["~/Documents/ph3/labs/mathematica/week6/recplot.pdf", recplot, "PDF"]
Export["~/Documents/ph3/labs/mathematica/week6/hannplot.pdf", hannplot, "PDF"]