System identification with FIR modell

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

Contents

Input dialog

prompt = {'Order of FIR model N','Block size K > N','Display L > N'};
dlg_title = 'lab13_1'; 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 = .25*sinc(.25*(-11:11)); % impulse response of FIR filter
a = 1;                      % FIR system
x = randn(1,K);             % white noise input signal
y = filter(b,a,x);          % simulated output signal of system under test
% y = y + sqrt(10^(-20/10))*randn(size(y)); % AWGN, -20dB

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) =  0.0205   ,  h[0]=  0.0205 
 b(1) =  0.0318   ,  h[1]=  0.0318 
 b(2) =  0.0250   ,  h[2]=  0.0250 
 b(3) = -0.0000   ,  h[3]= -0.0000 
 b(4) = -0.0322   ,  h[4]= -0.0322 
 b(5) = -0.0531   ,  h[5]= -0.0531 
 b(6) = -0.0450   ,  h[6]= -0.0450 
 b(7) =  0.0000   ,  h[7]=  0.0000 
 b(8) =  0.0750   ,  h[8]=  0.0750 
 b(9) =  0.1592   ,  h[9]=  0.1592 
 b(10) =  0.2251   ,  h[10]=  0.2251 
 b(11) =  0.2500   ,  h[11]=  0.2500 
 b(12) =  0.2251   ,  h[12]=  0.2251 
 b(13) =  0.1592   ,  h[13]=  0.1592 
 b(14) =  0.0750   ,  h[14]=  0.0750 
 b(15) =  0.0000   ,  h[15]=  0.0000 
 b(16) = -0.0450   ,  h[16]= -0.0450 
 b(17) = -0.0531   ,  h[17]= -0.0531 
 b(18) = -0.0322   ,  h[18]= -0.0322 
 b(19) = -0.0000   ,  h[19]= -0.0000 
 b(20) =  0.0250   ,  h[20]=  0.0250 
 b(21) =  0.0318   ,  h[21]=  0.0318 
 b(22) =  0.0205   ,  h[22]=  0.0205 
TSEopt = 3.55271e-015  for K = 51
empirical TSE  = 1.14839e-031  for impulse response of length 23

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_1 : 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')