P2.3
Generate the following periodic sequences and plot their samples (using the stem function)
over the indicated number of periods.
- 1 x (n) = {. . . , -2, -1, 0, 1, 2, . . .}periodic. Plot 5 periods
- 2x (n) = 𝑒0.1𝑛[u(n) – u(n – 20]periodic. Plot 3 periods.
- 3x (n) = sin(0.1πn)[u(n) – u(n – 10)]. Plot 4 periods.
- 4 x (n) = {. . . , 1, 2, 3, . . .}periodic + {. . . , 1, 2, 3, 4, . . .}periodic, 0 ≤ n ≤ 24. What is
%% P0203a: x1(n) = {...,-2,-1,0,1,2,-2,-1,0,1,2...}
periodic. 5 periods
clc; close all;
n1 = [-12:12]; x1 = [-2,-1,0,1,2];
x1 = x1'*ones(1,5); x1 = (x1(:))';
Hf_1 = figure;
set(Hf_1,'NumberTitle','off','Name','P0203a');
Hs = stem(n1,x1,'filled'); set(Hs,'markersize',2);
axis([min(n1)-1,max(n1)+1,min(x1)-1,max(x1)+1]);
xlabel('n','FontSize',8); ylabel('x_1(n)','FontSize',8);
title('Sequence x_1(n)','FontSize',8);
ntick = [n1(1):2:n1(end)]; ytick = [min(x1) - 1:max(x1) +
1];
set(gca,'XTickMode','manual','XTick',ntick);
set(gca,'YTickMode','manual','YTick',ytick);
print -deps2 ../EPSFILES/P0203a
%% P0203b: x2 = e ^ {0.1n} [u(n) - u(n-20)] periodic. 3
periods
clc; close all;
n2 = [0:21]; x2 = exp(0.1*n2).*(stepseq(0,0,21)-
stepseq(20,0,21));
x2 = x2'*ones(1,3); x2 = (x2(:))'; n2 = [-22:43];
Hf_1 = figure;
set(Hf_1,'NumberTitle','off','Name','P0203b');
Hs = stem(n2,x2,'filled'); set(Hs,'markersize',2);
axis([min(n2)-2,max(n2)+4,min(x2)-1,max(x2)+1]);
xlabel('n','FontSize',8); ylabel('x_2(n)','FontSize',8);
title('Sequence x_2(n)','FontSize',8);
ntick = [n2(1):4:n2(end)-5 n2(end)];
set(gca,'XTickMode','manual','XTick',ntick);
print -deps2 ../EPSFILES/P0203b;
%% P0203c: x1(n) = {...,-2,-1,0,1,2,-2,-1,0,1,2...} periodic. 4 periods
clc; close all;
n3 = [0:11]; x3 = sin(0.1*pi*n3).*(stepseq(0,0,11)-stepseq(10,0,11));
x3 = x3'*ones(1,4); x3 = (x3(:))'; n3 = [-12:35];
Hf_1 = figure; set(Hf_1,'NumberTitle','off','Name','P0203c');
Hs = stem(n3,x3,'filled'); set(Hs,'markersize',2);
axis([min(n3)-1,max(n3)+1,min(x3)-0.5,max(x3)+0.5]);
xlabel('n','FontSize',8); ylabel('x_3(n)','FontSize',8);
title('Sequence x_3(n)','FontSize',8);
ntick = [n3(1):4:n3(end)-3 n3(end)];
set(gca,'XTickMode','manual','XTick',ntick);
print -deps2 ../EPSFILES/P0203c;
%% P0203d x1(n) = {...,-2,-1,0,1,2,-2,-1,0,1,2...} periodic. 5 periods
clc; close all;
n4 = [0:24]; x4a = [1 2 3]; x4a = x4a'*ones(1,9); x4a = (x4a(:))';
% There is tatolly 25 pionts between 0 and 24 and therefore x4a and x4b both need another more
% period.
x4b = [1 2 3 4]; x4b = x4b'*ones(1,7); x4b = (x4b(:))';
x4 = x4a(1:25) + x4b(1:25);
Hf_1 = figure; set(Hf_1,'NumberTitle','off','Name','P0203d');
Hs = stem(n4,x4,'filled'); set(Hs,'markersize',2);
axis([min(n4)-1,max(n4)+1,min(x4)-1,max(x4)+1]);
xlabel('n', 'FontSize', 8); ylabel('x_4(n)','FontSize',8);
title('Sequence x_4(n):Period = 12','FontSize',8);
ntick = [n4(1) :2:n4(end)]; set(gca,'XTickMode','manual','XTick',ntick);
print -deps2 ../EPSFILES/P0203d;
Leave a comment