CHAPTER 2
Discrete-Time SignalsandSystems
Tutorial Problems
1. (a) M ATLABscript:
% P0201a: Generate and plot unit sample
close all; clc
n = -20:40; % specifiy support of signal
deltan = zeros(1,length(n)); % define signal
deltan(n==0)=1;
% Plot:
hf = figconfg(’P0201a’,’small’);
stem(n,deltan,’fill’)
axis([min(n)-1,max(n)+1,min(deltan)-0.2,max(deltan) +0.2])
xlabel(’n’,’fontsize’,LFS); ylabel(’\delta[n]’,’font size’,LFS);
title(’Unit Sample \delta[n]’,’fontsize’,TFS)
−20−10 010203040−0.200.20.40.60.81
nδ[n]Unit Sample δ[n]
FIGURE2.1: unit sample δ[n].
1 CHAPTER2. Discrete-Time Signals and Systems 2
(b) MATLABscript:
% P0201b: Generate and plot unit step sequence
close all; clc
n = -20:40; % specifiy support of signal
un = zeros(1,length(n)); % define signal
un(n>=0)=1;
% Plot:
hf = figconfg(’P0201b’,’small’);
stem(n,un,’fill’)
axis([min(n)-1,max(n)+1,min(un)-0.2,max(un)+0.2])
xlabel(’n’,’fontsize’,LFS); ylabel(’u[n]’,’fontsize’ ,LFS);
title(’Unit Step u[n]’,’fontsize’,TFS)
−20−10 010203040−0.200.20.40.60.81
nu[n]Unit Step u[n]
FIGURE2.2: unit step u[n].
(c) MATLABscript:
% P0201c: Generate and plot real exponential sequence
close all; clc
n = -20:40; % specifiy support of signal
x1n = 0.8.^n; % define signal
% Plot:
hf = figconfg(’P0201c’,’small’);
stem(n,x1n,’fill’)
axis([min(n)-1,max(n)+1,min(x1n)-5,max(x1n)+5])
xlabel(’n’,’fontsize’,LFS); ylabel(’x_1[n]’,’fontsiz e’,LFS);
title(’Real Exponential Sequence x_1[n]’,’fontsize’,TF S)
(d) MATLABscript: CHAPTER2. Discrete-Time Signals and Systems 3
−20−10 010203040020406080
nx1[n]Real Exponential Sequence x1[n]
FIGURE2.3: real exponential signal x1[n] = (0.80)n.
% P0201d: Generate and plot complex exponential sequence
close all; clc
n = -20:40; % specifiy support of signal
x2n = (0.9*exp(j*pi/10)).^n; % define signal
x2n_r = real(x2n); % real part
x2n_i = imag(x2n); % imaginary part
x2n_m = abs(x2n); % magnitude part
x2n_p = angle(x2n); % phase part
% Plot:
hf = figconfg(’P0201d’);
subplot(2,2,1)
stem(n,x2n_r,’fill’)
axis([min(n)-1,max(n)+1,min(x2n_r)-1,max(x2n_r)+1])
xlabel(’n’,’fontsize’,LFS); ylabel(’Re\{x_2[n]\}’,’f ontsize’,LFS);
title(’Real Part of Sequence x_2[n]’,’fontsize’,TFS)
subplot(2,2,2)
stem(n,x2n_i,’fill’)
axis([min(n)-1,max(n)+1,min(x2n_i)-1,max(x2n_i)+1])
xlabel(’n’,’fontsize’,LFS); ylabel(’Im\{x_2[n]\}’,’f ontsize’,LFS);
title(’Imaginary Part of Sequence x_2[n]’,’fontsize’,TF S)
subplot(2,2,3)
stem(n,x2n_m,’fill’)
axis([min(n)-1,max(n)+1,min(x2n_m)-1,max(x2n_m)+1])
xlabel(’n’,’fontsize’,LFS); ylabel(’|x_2[n]|’,’fonts ize’,LFS);
title(’Magnitude of Sequence x_2[n]’,’fontsize’,TFS)
subplot(2,2,4) CHAPTER2. Discrete-Time Signals and Systems 4
stem(n,x2n_p,’fill’)
axis([min(n)-1,max(n)+1,min(x2n_p)-1,max(x2n_p)+1])
xlabel(’n’,’fontsize’,LFS); ylabel(’\phi(x_2[n])’,’f ontsize’,LFS);
title(’Phase of Sequence x_2[n]’,’fontsize’,TFS)
−20−10 010203040−4−202468
nRe{x2[n]}Real Part of Sequence x2[n]
−20−10 010203040−20246
nIm{x2[n]}Imaginary Part of Sequence x2[n]
−20−10 01020304002468
n|x2[n]|Magnitude of Sequence x2[n]
−20−10 010203040−4−2024
nφ(x2[n])Phase of Sequence x2[n]
FIGURE2.4: complex exponential signal x2[n] = (0.9ejπ/10)n.
(e) MATLABscript:
% P0201e: Generate and plot real sinusoidal sequence
close all; clc
n = -20:40; % specifiy support of signal
x3n = 2*cos(2*pi*0.3*n+pi/3); % define signal
% Plot:
hf = figconfg(’P0201e’,’small’);
stem(n,x3n,’fill’)
axis([min(n)-1,max(n)+1,min(x3n)-0.5,max(x3n)+0.5])
xlabel(’n’,’fontsize’,LFS); ylabel(’x_3[n]’,’fontsiz e’,LFS);
title(’Real Sinusoidal Sequence x_3[n]’,’fontsize’,TFS )