
先上代码,后出结果图。
a、
n = [-5:5]; x=2*impseq(-2,-5,5) - impseq(4,-5,5); set(gcf,‘Color‘,[1,1,1]) % 改变坐标外围背景颜色 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 = 10 * exp(-0.3*(n-10)) .* (stepseq(10,0,20) - stepseq(20,0,20)); x = x1 + x2; set(gcf,‘Color‘,[1,1,1]) % 改变坐标外围背景颜色 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]) % 改变坐标外围背景颜色 stem(n,x); title(‘Sequence in Problem 2.1c‘) xlabel(‘n‘); ylabel(‘x(n)‘); grid on;
 
  
d、
%% 
%% 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 书内练习Example 2.1
原文:http://www.cnblogs.com/ky027wh-sx/p/5998561.html