%% System Identification of FIR Filter Using Adaptive Lattice Filter
% Note: If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).

ha = fir1(31,0.5);
fir = dsp.FIRFilter('Numerator',ha); % FIR system to be identified 
iir = dsp.IIRFilter('Numerator',sqrt(0.75),...
        'Denominator',[1 -0.5]);
x = iir(sign(randn(2000,25))); 
n = 0.1*randn(size(x));             % Observation noise signal 
d = fir(x)+n;                   % Desired signal 
l = 32;                             % Filter length 
m  = 5;                             % Decimation factor for analysis
                                    % and simulation results 
ha = dsp.AdaptiveLatticeFilter(l); 
[simmse,meanWsim,Wsim,traceKsim] = msesim(ha,x,d,m);
plot(m*(1:length(simmse)),10*log10(simmse));
xlabel('Iteration'); ylabel('MSE (dB)');
title('Learning curve for Adaptive Lattice filter used in system identification')