📄 exadapsp.m
字号:
% --------------------------------
% +++++ NOTE: THIS IS A MATLAB PROGRAM +++++++
% --------------------------------
% **** This Program solves the Problem in Fig 8.7 (p 169) in notes ****
% (Same as Fig 9.19 of Haykin)
% (i.e. can be used to produce Fig 8.11 (Haykin Figure 9.23) )
%
w = 3.1 ; ite = 1500 ; mu = 0.025 ; ens = 200 ;
%
% h ==> channel response
% x ==> channel input
% del ==> used to delay input and
% obtain the desired response
% u ==> tap weight vector
% cw ==> FIR filter weights
%
h = 0.5*(1.0 + cos(2*pi*([0:4]' - 2)/w)) ;
h(1) = 0 ; h(5) = 0 ;
enmse = zeros(1, ite);
for kk = 1:ens
del = zeros(8,1) ;
x = zeros(5,1) ;
cw = zeros(11,1) ;
u = zeros(11,1) ;
for k = 1:ite
del(2:8) = del(1:7);
x(2:5) = x(1:4);
% calculate the Bernoulli input
x(1) = 2*floor(rand(1,1)+0.5) - 1 ;
del(1) = x(1) ;
% calculate the tap inputs
y = h'*x + randn(1,1)*sqrt(0.001) ;
u(2:11) = u(1:10) ; u(1) = y ;
err = del(8) - cw'*u ;
cw = cw + mu*err*u;
mse(k) = err*err ;
end ; % end of k loop %
% now calculate the ensemble average
enmse = enmse + mse/ens ;
end ; % end of kk loop %
%
% Now plot one (last) realization and also
% ensemble average (learning curve).
%
plot([1:ite], log10(mse), [1:ite], log10(enmse)) ;
grid ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -