N=8; M=5;
x=randn(N,1); 
h=rand(M,1);
ND=N*M;
G=x*h.';
%Partial overlap at the beginning
ind=0;
for in=1:M-1,
    sum=0; 
    for jn=1:in,
    sum=sum+G(in-jn+1,jn);
    end
    ind=ind+1;
    Yc(ind,1)=sum;
end
%Region of full overlap
for in=M:N,
    sum=0; 
    for jn=1:M,
    sum=sum+G(in-jn+1,jn);
    end
    ind=ind+1;
    Yc(ind,1)=sum;
end
%Partial overlap at the end
for in=1:M-1,
    sum=0;
    im=0;
    for jn=in:M-1,
    sum=sum+G(N-im,jn+1);
    im=im+1;
    end
    ind=ind+1;
    Yc(ind,1)=sum;
end
%Method a above
Nf=N+M-1;
%Method b: FFT based 
Yf=ifft(fft(x,Nf).*fft(h,Nf));
%Method c:
Yh=convmtx(h,N)*x
%Method d 
y=conv(x,h);
%Method e
ye=cconv([x ; zeros(M,1)],[h ; zeros(N,1)]);
%They all yield the same convolution result
[y Yc Yf Yh ye(1:N+M-1,1)]
    