%Evan Witkoske
%Convolution problem HW 3.7
%ECE 301 7/2/09
close all clear all
x = input('Input array with brackets and commas between each component:')
h = input('Input array with brackets and commas between each component:')
x1 = length(x);
h1 = length(h);
%We have to add the zeros so if the two arrays are not the same size then the following command will add them %Matlab will not allow, like mathematics in general, two different sized arrays to be added together.
X1 = [x , zeros(1,x1)];
H1 = [h , zeros(1,h1)];
for i=1:x1+h1-1
Y(i)=0;
for j=1:x1
%this is a for loop within the first for loop, I just lost the spacing
if(i-j+1>0)
Y(i) = Y(i)+X1(j)*H1(i-j+1);
else end end end
>> help conv
CONV Convolution and polynomial multiplication. C = CONV(A, B) convolves vectors A and B. The resulting vector is length LENGTH(A)+LENGTH(B)-1. If A and B are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials. Class support for inputs A,B: float: double, single See also deconv, conv2, convn, filter and, in the signal Processing Toolbox, xcorr, convmtx.
Overloaded methods: gf/conv
Reference page in Help browser doc conv