%% Code by Ryne Rayburn

%% Performs convolution on inputted vectors x & y. Then displays the

%% answer (y).

clc;

clear all;

%%Input by user in vector format, i.e. [1,2,3,4,5,etc]

x=input('Enter vector x in [a,b,c] format: ');

h=input('Enter vector h in [a,b,c] format: ');

Lx=length(x); %%Length of vector x

Lh=length(h); %%Length of vector h

X=[x,zeros(1,Lh)]; %%Pads vector x with zeros

H=[h,zeros(1,Lx)]; %%Pads vector h with zeros

%%Padding with zeroes allows the vector arithmetic to be carried out

%%successfully, without errors

for(i=1:Lx+Lh-1)

 y(i)=0;
 for(j=1:Lx)
   if(i-j+1>0)
     y(i)=y(i)+X(j)*H(i-j+1);
   end
 end

end

y

Return to Homework 2

Alumni Liaison

Correspondence Chess Grandmaster and Purdue Alumni

Prof. Dan Fleetwood