Revision as of 11:11, 1 July 2009 by Nkgentry (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

CODE SHOWN BELOW:

clc; close all; clear all;

x1 = input('Please enter the x(t) vector with brackets: ');

x2 = input('Please enter the h(t) vector with brackets: ');

length_x1=length(x1);

length_x2=length(x2);

X1=[x1,zeros(1,length(x1))];

X2=[x2,zeros(1,length(x2))];

   for a=1:length_x1+length_x2-1
       y(a)=0;
     for b=1:length_x1
         if(a-b+1>0)
            y(a)=y(a)+X1(b)*X2(a-b+1);
         else
         end
     end
   end
   

fprintf('This give us the output:'); y


COMPARISON

Matlab's "conv" function works in a similar fashion to the above code.

Alumni Liaison

Have a piece of advice for Purdue students? Share it through Rhea!

Alumni Liaison