% % Filename: example6.m % % Description: This m-file convolves two signals and plots the result. % clear; % clear matlab memory f = [0.0 1.0 0.0 -1.0 0.0]; % define input signal f[k] for k=-1,...,3 h = [3.0 2.0 1.0 0.0 0.0]; % define unit-impulse response for k=-1,...3 k1 = -1:3; % discrete-time values for f[k], h[k] y = conv(f,h); % compute output y[k] via convolution k2 = -2:length(f)+length(h)-4; % create k-vector for plotting y[k] figure(1); clf; % clear figure 1 and plot all signals subplot(2,2,1); % plot f[k] stem(k1,f,'filled'); grid; xlabel('k'); ylabel('f[k]'); title('System Input'); subplot(2,2,2); % plot h[k] stem(k1,h,'filled'); grid; xlabel('k'); ylabel('h[k]'); title('System Unit Impulse Response'); subplot(2,1,2); % plot y[k] stem(k2,y,'filled'); grid; xlabel('k'); ylabel('y[k]'); title('System Output Via Convolution');MATLAB Plot Generated: