《DSP using MATLAB》Problem 6.6-LMLPHP

《DSP using MATLAB》Problem 6.6-LMLPHP

代码:

%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
%% Output Info about this m-file
fprintf('\n***********************************************************\n');
fprintf(' <DSP using MATLAB> Problem 6.6 \n\n'); banner();
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hb = [1 cos(0.1*pi) cos(0.2*pi) cos(0.3*pi) cos(0.4*pi)]; % numerator polynominal
ha = [1 0.8*sin(0.1*pi) (0.8^2)*sin(0.2*pi) (0.8^3)*sin(0.3*pi) (0.8^4)*sin(0.4*pi) (0.8^5)*sin(0.5*pi)]; xb = 1;
xa = [1 0 -1]; fprintf('\n FIR filter DIRECT-form: \n');
b = hb
a = conv(ha, xa)
%a = ha; 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)
C = 0; fprintf('\nConvert DIRECT-form to LATTICE-LADDER-form : \n');
[Klr, Clr] = dir2ladr(b, a) fprintf('\nConvert DIRECT-form to MATLAB LATTICE-LADDER-form : \n');
[K, V] = tf2latc(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) hladr = ladrfilt(Klr, Clr, delta) hdir = filter(b, a, delta)
% -------------------------------------------
% END check
% ------------------------------------------- figure('NumberTitle', 'off', 'Name', 'P6.6 hcas(n), hpar(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(n, hcas);
xlabel('n'); ylabel('hcas(n)');
title('hcas(n)'); grid on;
subplot(2,1,2); stem(n, hpar);
xlabel('n'); ylabel('hpar(n)');
title('hpar(n)'); grid on; figure('NumberTitle', 'off', 'Name', 'P6.6 hladr(n) hdir(n)')
set(gcf,'Color','white');
subplot(2,1,1); stem(n, hladr);
xlabel('n'); ylabel('hladr(n)');
title('hladr(n)'); grid on;
subplot(2,1,2); stem(n, hdir);
xlabel('n'); ylabel('hdir(n)');
title('hdir(n)'); grid on;

  运行结果:

直接形式系数

《DSP using MATLAB》Problem 6.6-LMLPHP

《DSP using MATLAB》Problem 6.6-LMLPHP

串联形式系数

《DSP using MATLAB》Problem 6.6-LMLPHP

并联形式系数

《DSP using MATLAB》Problem 6.6-LMLPHP

《DSP using MATLAB》Problem 6.6-LMLPHP

格型系数

《DSP using MATLAB》Problem 6.6-LMLPHP

《DSP using MATLAB》Problem 6.6-LMLPHP

05-11 18:17