EE342.01: MATLAB M-FILE FOR CONVOLVING TWO SIGNALS

MATLAB M-File example7.m:
%
%  Filename:  example7.m
%
%  Description:  This m-file convolves two signals and plots the result.
%

x = [0.5 0.5 0.5];                % define input signal x[n]
h = [3.0 2.0 1.0];                % define unit-pulse response h[n]

y = conv(x,h);                    % compute output y[n] via convolution

n = 0:(length(y)-1);              % create n-vector for plotting y[n]

stem(n,y);                        % plot y[n]
grid;
xlabel('n');
ylabel('y[n]');
title('Output of System via Convolution');
MATLAB Plot Generated: