System identification with FIR modell

design of TSE optimum non-recursive linear filter (FIR) for system identification ** lab13_1b.m * mw * 05/04/2007

Contents

Input dialog

prompt = {'Order of FIR model N','Block size K > N','Display L > N'};
dlg_title = 'lab13_1b'; num_lines = 1; def = {'22','51','41'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
if isempty(answer)
    Ns = 22; K = 51; L = 41;   % default
else
    Ns = str2num(answer{1});   % FIR model order
    K  = str2num(answer{2});   % number of samples (block size)
    L  = str2num(answer{3});   % length of displayed impulse response
end

System under test and filtering

b = [1 0 .81];         % numerator
a = [1 -.71 .25];      % denominator
x = randn(1,K);        % white noise input signal
y = filter(b,a,x);     % simulated output signal of system under test
y = y + sqrt(10^(-10/10))*randn(size(y)); % AWGN, -10dB

FIR model design

[bs,TSEopt] = design_fir_model(x,y,Ns);

Display on screen

fprintf('lab13_1 FIR model coefficients and system impulse response\n')
h = impz(b,a,L)';                % system impulse response
hh = [h zeros(1,L-length(h))];   % adjust length for print out and graphics
bb = [bs' zeros(1,L-length(bs))];% adjust length for print out and graphics
for k=1:Ns+1
    fprintf([' b(',num2str(k-1),') = %7.4f   ,  h[',num2str(k-1),']= %7.4f \n'],bb(k),hh(k))
end
TSE = sum((hh(1:Ns+1)-bb(1:Ns+1)).^2);  % total-squared error for the impulse responses
fprintf('TSEopt = %g  for K = %g\n',TSEopt,K)
fprintf('empirical TSE  = %g  for impulse response of length %g\n\n',TSE,Ns+1)
lab13_1 FIR model coefficients and system impulse response
 b(0) =  1.0161   ,  h[0]=  1.0000 
 b(1) =  0.7888   ,  h[1]=  0.7100 
 b(2) =  0.9872   ,  h[2]=  1.0641 
 b(3) =  0.6062   ,  h[3]=  0.5780 
 b(4) =  0.0416   ,  h[4]=  0.1444 
 b(5) = -0.1381   ,  h[5]= -0.0420 
 b(6) = -0.1842   ,  h[6]= -0.0659 
 b(7) = -0.0029   ,  h[7]= -0.0363 
 b(8) =  0.1239   ,  h[8]= -0.0093 
 b(9) =  0.0574   ,  h[9]=  0.0025 
 b(10) = -0.0586   ,  h[10]=  0.0041 
 b(11) =  0.1054   ,  h[11]=  0.0023 
TSEopt = 2.66951  for K = 51
empirical TSE  = 0.0833864  for impulse response of length 12

Graphics

Nfft = 1024; w = (0:Nfft/2-1)/(Nfft/2);
H = abs(fft(hh,Nfft)); H = H(1:Nfft/2);
B = abs(fft(bb,Nfft)); B = B(1:Nfft/2);
FIG1 = figure('Name',['lab13_1b : System identification  N = ',num2str(Ns)],...
    'NumberTitle','off');
subplot(3,2,1), stem(0:length(hh)-1,hh,'filled'),grid
xlabel('n \rightarrow'), ylabel('h[n] \rightarrow')
title('System impulse response')
subplot(3,2,3), plot(w,H,'LineWidth',2),grid
xlabel('\Omega / \pi \rightarrow'), ylabel('|H(e^{j\Omega})| \rightarrow')
title('System frequency response')
subplot(3,2,5), plot(w,20*log10(H),'LineWidth',2),grid
xlabel('\Omega / \pi \rightarrow'), ylabel('|H(e^{j\Omega})| in dB \rightarrow')
subplot(3,2,2), stem(0:length(bb)-1,bb),grid
xlabel('n \rightarrow'), ylabel('b[n] \rightarrow')
title('FIR-Model impulse response (o)')
hold on
plot(0:length(hh)-1,hh,'.')
hold off
subplot(3,2,4), plot(w,B,'LineWidth',2),grid
xlabel('\Omega / \pi  \rightarrow'), ylabel('|B(e^{j\Omega})| \rightarrow')
title('FIR-Model frequency response')
subplot(3,2,6), plot(w,20*log10(B),'LineWidth',2),grid
xlabel('\Omega / \pi  \rightarrow'), ylabel('|B(e^{j\Omega})| in dB \rightarrow')