function [ y ] = convolution2( h, x )

%CONVOLUTION computes the convolution for two DT LTI signals % y = convolution2(h,x) convolves vectors h and x. % Algebraically, convolution is the same operation as multiplying the % polynomials whose coefficients are the elements of h and x. % For more information, refer to the built in convolution command % (conv)

nh = numel(h); nx = numel(x); nv = nh + nx - 1;

r = h.' * x; b = zeros(nv,nh);

c = arrayfun(@(x)(x-1)*nv+(x:x+nx-1),1:nh,'uni',false); c = cat(1,c{:});

b(c) = r; r = sum(b.');

y = r;



function [ y ] = convolution3( h, x )

%CONVOLUTION computes the convolution for two DT LTI signals % y = convolution(h,x) convolves vectors h and x. % Algebraically, convolution is the same operation as multiplying the % polynomials whose coefficients are the elements of h and x. % For more information, refer to the built in convolution command % (conv)


X = fft([x zeros(1,length(h)-1)]); H = fft([h zeros(1,length(x)-1)]);

y = ifft(X.*H);

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett