Digital Signal Processing Reference
In-Depth Information
10.9.2 Convolution
Consider two time-limited DT sequences x 1 [ k ] and x 2 [ k ], where x 1 [ k ] = 0
within the range k 1 k k u 1 and x 2 [ k ] = 0 within the range k 2 k k u 2 .
The length K 1 of the DT sequence x 1 [ k ] is given by K 1 = k u 1 k 1 + 1 samples,
while the length K 2 of the DT sequence x 2 [ k ]is K 2 = k u 2 k 2 + 1 samples.
In M ATLAB , two vectors are required to represent each DT signal. The first
vector contains the sample values, while the second vector stores the time
indices corresponding to the sample values. For example, the following DT
sequence:
1
k =− 1
1
k = 0
x [ k ] =
2
k = 1
0
otherwise
has the following M ATLAB representation:
>> kx = [-1 0 1];
% time indices where x is nonzero
>> x = [-1 1 2];
% Sample values for DT sequence x
To perform DT convolution, M ATLAB provides a built-in function conv .We
illustrate its usage by repeating Example 10.9 with M ATLAB .
Example 10.19
Consider
the
following
two
DT
sequences
x [ k ]
and
h [ k ]
specified
in
Example 10.9:
1
k =− 1
3
k =− 1 , 2
1
k = 0
1
k = 0
x [ k ] =
and
h [ k ] =
2
k = 1
2
k = 1 , 3
0
otherwise
0
otherwise.
Compute the convolution y [ k ] = x [ k ] h [ k ] using M ATLAB .
Solution
The M ATLAB code used to convolve the two functions is given below. As
before, the explanation follows each instruction in the form of comments.
>> kx = [-1 0 1]; % time indices where x is nonzero
>> x = [-1 1 2]; % Sample values for DT sequence x
>>kh=[-10123]; %time indices where y is nonzero
>>h=[31-23-2]; % Sample values for DT sequence y
>> y = conv(x,h); % Convolve x with h
>> ky = kx(1)+kh(1):kx(length(kx))+kh(length(kh));
% ky= time indices for y
In the above instructions, note that M ATLAB does not calculate the indices of
the result of convolution. These indices have to be calculated separately based
Search WWH ::




Custom Search