《DSP using MATLAB》Problem 6.5

        代码:

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

');

banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

b = [1 -2.828 3.97 -2.828 1]; a = [1 -2.536 3.215 -2.054 0.6560];

fprintf('
Convert DIRECT-form to CASCADE-form :     
');
[b0, Bc, Ac] = dir2cas(b, a)

fprintf('
Convert DIRECT-form to PARALLEL-form :     
');
[C, Bp, Ap] = dir2par(b, a) 


% -----------------------------------------
%     START check
% -----------------------------------------
n = [0:7];
delta = impseq(0, 0, 7)
%format long
format  short
hcas = casfiltr(b0, Bc, Ac, delta)
hpar = parfiltr(C, Bp, Ap, delta)
hdir = filter(b, a, delta)
% -------------------------------------------
%       END check
% -------------------------------------------


figure('NumberTitle', 'off', 'Name', 'P6.5 hcas(n), hpar(n) and hdir(n)')
set(gcf,'Color','white'); 
subplot(3,1,1); stem(n, hcas); 
xlabel('n'); ylabel('hcas(n)');
title('hcas(n)');  grid on;
subplot(3,1,2); stem(n, hpar); 
xlabel('n'); ylabel('hpar(n)');
title('hpar(n)');  grid on;
subplot(3,1,3); stem(n, hdir);  
xlabel('n'); ylabel('hdir(n)');
title('hdir(n)');  grid on;

  运行结果:

       串联形式的系数

         并联形式的系数

牢记: 1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。
原文地址:https://www.cnblogs.com/ky027wh-sx/p/9576634.html