%Vishal Ramani

%Homework 2 Problem 3.7

%ECE 301 Summer 2009


%This Program computes the convolution of two inputs x(t) and h(t)with the

%final output being y(t).

%The user will enter a sequence of numbers for x(t) and numbers for

%h(t) in the form of a vector.

%The program below will compute the convolution, y(t), based on the users

%input.

%Part 1: Asks for input values from user.

x = input('Enter a sequence of numbers, x, EX: [1,2,3]: ');

h = input('Enter a second sequence of numbers, h, EX: [1,2,3]: ');


%Part 2: Calculates length of vector specified by the user.

Lgthx = length(x); %%The Length of vector x specified by user.

Lgthh = length(h); %%The Length of vector h specified by user.


%Part 3: Pading the 2 vectors from above with their zeros (Makes answers more accurate).

X=[x,zeros(1,Lgthh)]; .

H=[h,zeros(1,Lgthx)];

%Loop Used for the Convolution Computation

for(i = 1:Lgthx + Lgthh - 1)


y(i) = 0;


for(j = 1:Lgthx)


  if(i - j + 1 > 0)


    y (i) = y(i) + X(j) * H(i-j+1);


  end
end

end


y %Displays the final output, y.


Return to Homework 2

Alumni Liaison

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

Dr. Paul Garrett