《DSP using MATLAB》Problem 6.5

        代码:

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

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

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

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

fprintf('\nConvert DIRECT-form to PARALLEL-form :     \n');
[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;

  运行结果:

       串联形式的系数

         并联形式的系数

猜你喜欢

转载自www.cnblogs.com/ky027wh-sx/p/9576634.html