function y=MyConv1D(x,h)
%Implement two one dimensional arrays liner convolution
%x is the Input signal,h is the respond signal and y is the result of
%liner convolution
m=length(x);
n=length(h);
%Make the longer array to be Input signal,for save calculate time
if(m<n) % if the length of x is smaller than h,exchange them
temp1=x;
x=h;
h=temp1;
temp1=m;
m=n;
n=temp1;
end
% CONV(A,B) is the same as CONV(B,A), but we can make it go
% substantially faster if we swap arguments to make the first
% argument to filter the shorter of the two.
%reverse h for preparing circulate convolution calculation
if rem(n,2) == 0 ;
for i=1:(n/2); %if the length of h is even
temp=h(i);
h(i)=h(n-i+1);
h(n-i+1)=temp;
end ;
else ;
for i=1:(n/2)+1; %if the length of h is odd
temp=h(i);
h(i)=h(n-i+1);
h(n-i+1)=temp;
end
end
%define the length of ouput result y
n_yLength=m+n-1;
%compensate zeros to input signal x for calculating
x=[zeros(1,n),x,zeros(1,n-1)];
y=zeros(1,n_yLength);
for k=1:n_yLength
s=0;
for i=1:n;
s=s+x(k+i)*h(i); %Calculate y
end
y(k)=s;
end