First the code, then the result diagram.
A
n = [ -5:5];x=2*impseq ( -2,-5,5)-Impseq (4,-5,5); set (GCF, ' color ', [1,1,1]) % change coordinates peripheral background color stem (n,x); title (' Sequence In problem 2.1a '); Xlabel (' n '); Ylabel (' x (n) '); Grid on;
B
n = [0:20]; X1 = N. * (Stepseq (0,0,20)-Stepseq (10,0,20)); x2 = ten * exp ( -0.3* (N-10)). * (Stepseq (10,0,20)-Stepseq (20,0,20)); x = x1 + X2;set (GCF, ' Color ', [1,1,1]) % change coordinates peripheral background color stem (n,x); title (' Sequence in Problem 2.1b ') Xlabel (' n '); Ylabel (' X (n) ') ; grid on;
C
n = [0:50]; x = cos (0.04*pi*n) +0.2*randn (Size (n)), set (GCF, ' color ', [1,1,1]) % change coordinates peripheral background color stem (n,x); title (' Sequence in problem 2.1c ') Xlabel (' n '); Ylabel (' x (n) '); Grid on;
D
Percent of a percent X (n) = {..., 5,4,3,2,1,5,4,3,2,1,5,4,3,2,1,...}; -10<n<9%% *n = [ -10:9]; x = [5,4,3,2,1];xtilde = X ' * ones (1,4); Xtilde = (Xtilde (:)) ';%subplot (2,2,4); set (GCF, ' Color ', ' white '); stem (N,xtilde); Title (' Sequence in Problem 2.1d ') Xlabel (' n '); Ylabel (' Xtilde (n) '); grid on;
DSP using Matlab Book in practice example 2.1