www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/IdentifyADigitalFilterWithFastTransversalExample.m

    %% System Identification Using Fast Transversal Filter
%%
% *Note*: This example runs only in R2016b or later. If you are using an
% earlier release, replace each call to the function with the equivalent
% |step| syntax. For example, myObject(x) becomes step(myObject,x).

%%
hftf1 = dsp.FastTransversalFilter(11,'ForgettingFactor',0.99);
hfilt = dsp.FIRFilter;
hfilt.Numerator = fir1(10,.25);
x = randn(1000,1);
d = hfilt(x) + 0.01*randn(1000,1);
[y,e] = hftf1(x,d);
w = hftf1.Coefficients;
subplot(2,1,1);
plot(1:1000,[d,y,e]);
title('System Identification of an FIR filter');
legend('Desired','Output','Error');
xlabel('time index');
ylabel('signal value');
subplot(2,1,2); 
stem([hfilt.Numerator; w].');
legend('Actual','Estimated'); 
xlabel('coefficient #'); 
ylabel('coefficient value');