Convolution of Two Finite-Duration Signals Using MATLAB
For the signals x[n] and g[n] depicted in Fig. 3.24, use MATLAB to compute and plot c[n] = x[n] ∗ g[n].
>> x = [0 1 2 3 2 1]; g = [1 1 1 1 1 1];
>> n = (0:1:length(x)+length(g)-2);
>> c = conv(x,g);
>> clf; stem(n,c,’k’); xlabel(’n’); ylabel(’c[n]’); axis([-0.5 10.5 0 10]);