《DSP using MATLAB》Problem 2.16

Posted 沧海一粟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《DSP using MATLAB》Problem 2.16相关的知识,希望对你有一定的参考价值。

     先由脉冲响应序列h(n)得到差分方程系数,过程如下:

代码:

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf(\'\\n***********************************************************\\n\');
fprintf(\'        <DSP using MATLAB> Problem 2.16 \\n\\n\');

banner();
%% ------------------------------------------------------------------------


%% ------------------------------------------------------
%%              sequence of 51 samples
%% ------------------------------------------------------
nx1 = [-1:49]; x1 = (0.8 .^ nx1) .* stepseq(0, -1, 49);  
nh1 = [-1:49]; h1 = ( (-0.9).^nh1 ) .* stepseq(0, -1, 49);

[y1, ny1] = conv_m(x1, nx1, h1, nh1);

figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 2.16\')
set(gcf,\'Color\',[1,1,1])                  % 改变坐标外围背景颜色

subplot(3,1,1); stem(nx1, x1); title(\'x1 sequence\');
xlabel(\'n\'); ylabel(\'x(n)\') ;
grid on
subplot(3,1,2); stem(nh1, h1); title(\'h1 sequence\');
xlabel(\'n\'); ylabel(\'h1(n)\');
grid on;
subplot(3,1,3); stem(ny1, y1); title(\'y1=x1*h1 sequence\');
xlabel(\'n\'); ylabel(\'y1(n)\');
grid on;


%% -----------------------------------------------------
%%         Trancate to 26 samples
%% -----------------------------------------------------
nx2 = [-1:24]; x2 = (0.8 .^ nx2) .* stepseq(0, -1, 24);  
nh2 = [-1:24]; h2 = ( (-0.9).^nh2 ) .* stepseq(0, -1, 24);

[y2, ny2] = conv_m(x2, nx2, h2, nh2);

figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 2.16\')
set(gcf,\'Color\',[1,1,1])                  % 改变坐标外围背景颜色

subplot(3,1,1); stem(nx2, x2); title(\'x2 sequence\');
xlabel(\'n\'); ylabel(\'x2(n)\') ;
grid on
subplot(3,1,2); stem(nh2, h2); title(\'h2 sequence\');
xlabel(\'n\'); ylabel(\'h2(n)\');
grid on;
subplot(3,1,3); stem(ny2, y2); title(\'y2=x2*h2 sequence\');
xlabel(\'n\'); ylabel(\'y2(n)\');
grid on;


%% ----------------------------------------------------------
%%            filter function
%% ----------------------------------------------------------
b = [1]; a = [1, 0.9];

y3 = filter(b, a, x1);


figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 2.16\')
set(gcf,\'Color\',[1,1,1])                  % 改变坐标外围背景颜色

%subplot(3,1,3); 
stem(nx1, y3); title(\'y3 sequence\');
xlabel(\'n\'); ylabel(\'y3(n)\');
grid on;

  运行结果:

 

以上是关于《DSP using MATLAB》Problem 2.16的主要内容,如果未能解决你的问题,请参考以下文章

《DSP using MATLAB》Problem 5.7

《DSP using MATLAB》Problem 6.7

《DSP using MATLAB》Problem 6.8

《DSP using MATLAB》Problem 3.12

《DSP using MATLAB》Problem 4.17

《DSP using MATLAB》Problem 3.5