Professional Documents
Culture Documents
Convolution in Mat Lab
Convolution in Mat Lab
Convolution in Mat Lab
Rather than writing and executing commands one line at a time, it is very common to write a complete
program using a text editor and then run it as a single entity.
e.g.
%The program in file HELLO.M greets you and asks for your name.
%Then greets you by name and tells you the date.
disp(Hello! ho are you!"#
name $ input (%lease enter your name en&losed bet'een (uotes #)
d $ date)
ans'er $ * Hello name Today is d ."+)
disp(ans'er#
In Matlab go to File New Script.
This will open a text editor into which you can enter the above program and save as hello.m. When
finished enter save as and note the path. It should be in
C!"ocuments and #ettings!studentid\My "ocuments!M$T%$& and appear in the left hand window of
Matlab.
'ou may now need to set a new path to the directory you are using. This may be done under file/set path
and select add folder then navigate to the folder you are using (normally the path is already set).
Convolution in Matlab
Exercise 1
Convolve the following by hand
x1 =[4 2 6 3 8 1 5];
x2=[3 8 6 5 !];
4 2 6 3 8 1 5
3 8 6 6 !
*
Exercise 2
%og on to Matlab and enter
x1 =[2"4 3"6 #"2 5"3 1"4 4"4 3"6];
x2=[3"1 3"8 5"2 !"! 2"5 4"6];
$=conv%x1&x2'
Write down the output
'ou will note that there are no mar+er arrows in this se,uence, which mean that the se,uences start from
x - ..
/owever if the se,uences do not start at x - . then the problem is a little more complicated.
Consider the following se,uence
x*0n1 2 x30n1 where
x*0n1-43.5 6.7 ..3 8.6 *.5 5.5 6.79
x30n1-4 6.* 6.: 8.3 ;.; 3.8 5.79