《DSP using MATLAB》Problem 4.15
Posted 沧海一粟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《DSP using MATLAB》Problem 4.15相关的知识,希望对你有一定的参考价值。
只会做前两个,
代码:
%% ---------------------------------------------------------------------------- %% Output Info about this m-file fprintf(\'\\n***********************************************************\\n\'); fprintf(\' <DSP using MATLAB> Problem 4.15 \\n\\n\'); banner(); %% ---------------------------------------------------------------------------- %% ---------------------------------------------------- %% 1 h(n)=[5(0.25)^n]u(n) %% x(n)=(0.25^n)u(n) %% ---------------------------------------------------- n = [0:9]; h1 = 5 * (1/4) .^ n .* stepseq(0, 0, 9); x = (1/4) .^ n; figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 4.15 h1(n) x(n)\') set(gcf,\'Color\',\'white\'); subplot(2,1,1); stem(n, h1); xlabel(\'n\'); ylabel(\'h(n)\'); grid on; title(\'h(n)=[5(1/4)^n]u(n)\'); subplot(2,1,2); stem(n, x); xlabel(\'n\'); ylabel(\'x\'); grid on; title(\'x(n)=(1/4)^nu(n)\'); b1 = [5]; a1 = [1, -1/4]; figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 4.15 H1(z) pole-zero\') set(gcf,\'Color\',\'white\'); zplane(b1, a1); title(\'pole-zero plot\'); grid on; y1 = filter(b1, a1, x); [y1_chk, ny1_chk] = conv_m(h1, n, x, n); figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 4.15 y1(n)\') set(gcf,\'Color\',\'white\'); subplot(2,1,1); stem([0:length(y1)-1], y1); xlabel(\'n\'); ylabel(\'h(n)\'); grid on; title(\'y(n)=filter(b, a, x)\'); subplot(2,1,2); stem(ny1_chk, y1_chk); xlabel(\'n\'); ylabel(\'y\'); grid on; title(\'y(n)=h(n)*x(n)\'); %% ---------------------------------------------------- %% 2 h(n)=[n(1/3)^n+(-1/4)^n]u(n) %% x(n)=(0.25^n)u(n) %% ---------------------------------------------------- n = [0:9]; h2 = (n .* (1/3) .^ n + (-1/4) .^ n ) .* stepseq(0, 0, 9); x = (1/4) .^ n; figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 4.15 h2(n) x(n)\') set(gcf,\'Color\',\'white\'); subplot(2,1,1); stem(n, h2); xlabel(\'n\'); ylabel(\'h(n)\'); grid on; title(\'h(n)=[n(1/3)^n]u(n) + (-1/4)^nu(n)\'); subplot(2,1,2); stem(n, x); xlabel(\'n\'); ylabel(\'x\'); grid on; title(\'x(n)=(1/4)^nu(n)\'); %b2 = [0, 12, 48, -1]; a2 = [144, -24, -23, 2, 1]; b2 = [1, -1/3, 7/36]; a2 = [1, -5/12, -1/18, 1/36]; figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 4.15 H2(z) pole-zero\') set(gcf,\'Color\',\'white\'); zplane(b2, a2); title(\'pole-zero plot\'); grid on; y2 = filter(b2, a2, x); [y2_chk, ny2_chk] = conv_m(h2, n, x, n); figure(\'NumberTitle\', \'off\', \'Name\', \'Problem 4.15 y2(n)\') set(gcf,\'Color\',\'white\'); subplot(2,1,1); stem([0:length(y2)-1], y2); axis([0, 9, 0, 1]); xlabel(\'n\'); ylabel(\'h(n)\'); grid on; title(\'y(n)=filter(b, a, x)\'); subplot(2,1,2); stem(ny2_chk, y2_chk); axis([0, 9, 0, 1]); xlabel(\'n\'); ylabel(\'y\'); grid on; title(\'y(n)=h(n)*x(n)\');
运行结果:
以上是关于《DSP using MATLAB》Problem 4.15的主要内容,如果未能解决你的问题,请参考以下文章
《DSP using MATLAB》Problem 3.12