m;t0=2;t=-t0:0.01:t0;x=(1+cos(pi*t)).*(u(t+1)-u(t-1));subplot(221);plot(t,x);gridon,axis([-2,2,-0.5,2.5]);title('Originalsignalx(t)');xlabel('Timet');ws=a*wm;Ts=2*pi/ws;N=fix(t0/Ts);n=-N:N;nTs=n*Ts;xs=(1+cos(pi*nTs)).*(u(nTs+1)-u(nTs-1));subplot(2,2,2)stem(n,xs,'.');xlabel('Timeindexn');gridon,title('Sampledversionx[n]');xr=zeros(1,length(t));L=length(-N:N);xa=xr;figure(2);stem(nTs,xs,'.');xlabel('Timeindexn');gridon;holdonfori=1:Lm=(L-1)/2+1-i;xa=Ts*(wc)*xs(i)*sinc((wc)*(t+m*Ts)/pi)/pi;plot(t,xa,'b:');axis([-2,2,-0.5,2.5]);holdonpausexr=xr+xa;endplot(t,xr,'r');axis([-2,2,-0.5,2.5]);holdonfigure(1);subplot(223)plot(t,xr,'r');axis([-2,2,-0.5,2.5]);xlabel('Timet');gridontitle('Reconstructedsignalxr(t)');error=abs(xr-x);subplot(2,2,4)plot(t,error);gridontitle('Error');xlabel('Timet')a=1a=4a=8