EE342.01: MATLAB M-FILE FOR PLOTTING COMBINATION DISCRETE-TIME SIGNALS

MATLAB M-File example3.m:
%
%  Filename:  example3.m
%
%  Description:  This m-file plots the combination discrete-time
%                signal x[n] = 2delta[n+2] - delta[n]
%                              + e^n(u[n+1]-u[n-2]).
%

n = -3:3;                             % define discrete-time variable

                                      % define x[n] = 
x = 2.*((n >= -2) - (n >= -1)) ...    % 2delta[n+2]
    - 1.*((n >= 0) - (n >= 1)) ...    % -delta[n]
    + exp(n).*((n >= -1) - (n >= 2)); % e^n(u[n+1]-u[n-2])

stem(n,x);                            % plot x[n] vs n
xlabel('n');                          % label plot
ylabel('x[n]');
title('EE342.01:  Example 3 - A Combination Signal');
MATLAB Plot Generated: