Contents
b = [1 2 1]; a = [1 -1.4 .74];
Impulse response
N = 40;
x = [1 zeros(1,N)];
hm = filter(b,a,x);
p = roots(a); z = p(1); r = abs(z); w = angle(z);
B = -j*(b(1)*z^2 + b(2)*z + b(3)) / (z*2*imag(z));
n = 0:N;
ha = 2*(r.^n).*(real(B)*cos(w*n) - imag(B)*sin(w*n));
ha(1) = ha(1) + b(3)/r^2;
Time-correlation sequence
Rm = conv(ha,fliplr(ha));
B = -j*(b(1)*z^2 + b(2)*z + b(3)) / (z*2*imag(z));
B = B*(b(1)+b(2)*z+b(3)*z^2) / (1+a(2)*z+a(3)*z^2);
Ra = 2*(r.^n).*(real(B)*cos(w*n) - imag(B)*sin(w*n));
Ra(1) = Ra(1) + b(1)*b(3)/r^2;
Ra = [Ra(N+1:-1:2) Ra];
fprintf('lab3_1: energy of impulse response = %g\n',Ra(N+1))
lab3_1: energy of impulse response = 82.8054
Graphics - Impulse response and time acf
FIG1 = figure('Name','lab3_1 : Impulse response and time-correlation function',...
'NumberTitle','off');
subplot(2,1,1), plot(0:N,ha,':',0:N,hm,'o'), grid
xlabel('n \rightarrow'), ylabel('h[n] \rightarrow')
title('Impulse response')
subplot(2,1,2),plot(-N:N,Rm,'o',-N:N,Ra,':'), grid
xlabel('l \rightarrow'), ylabel('R_{hh}[l] \rightarrow')
title('Time auto-correlation function')