set(0,'defaultaxesfontsize',22);
clear all
clf
k0=1; N=16; M=3;
w0=2*pi*k0/N;
n=[0:N-1];
x=cos(w0*n);
h=[1 2 1];
Hk=h(1)+h(2)*exp(-j*w0)+h(3)*exp(-j*2*w0);
Hkm=abs(Hk);  Hka=angle(Hk);
yf=Hkm*cos(w0*n+Hka);
y=conv(x,h); z=y;
Lt=M-1;
z(1:Lt)=z(1:Lt)+y(end-Lt+1:end);
zf=z(1:N);
figure(1)
plot(y,'r','Linewidth',3)
hold on
plot(zf,'b','Linewidth',3)
plot(yf,'k','Linewidth',3)
hold off