from Covolution function by Manish Agrawal
Using this function you can understand the basic algorithm of convolution.

conv_func(a,b)%a and b
function [c]= conv_func(a,b)%a and b
m=length(a);%length of a
n=length(b);%length of b
k=1;
sum=0;
for i=1:m+n-1
    if(i<=m)
        for j=1:k;
            if(j<m+1 & k+1-j<n+1)
            sum=sum+a(j)*b(k+1-j);
            end
        end
       c(i)=sum;
      sum=0;
       k=k+1;
    end
    if(i>m)
        for j=k-1:-1:1
            if(j<m+1 & k+1-j<n+1)
                sum=sum+a(j)*b(k+1-j);
            end
        end
        c(i)=sum;
        sum=0;
        k=k+1;
    end       
 end
 figure;
plot(c);
d=convn(a,b);%convolution using convn matlab command to compare
figure;
plot(d);

Contact us at files@mathworks.com