fg_09_04.m

来自「英文书《Digital Signal Processing with Examp」· M 代码 · 共 43 行

M
43
字号
% fg_09_04    MSE contour plot w/ ideal & LMS weight tracks.
M=140;
phi=cos(2*pi*[0:12]/12);
Phiff=[phi(1) phi(2); phi(2) phi(1)];
phifd=[phi(2); phi(3)];
bopt=Phiff\phifd;
% Plot the contours.
db=1.99;
b0=linspace(bopt(1)-db,bopt(1)+db,M);
b1=linspace(bopt(2)-db,bopt(2)+db,M);
mse=zeros(M,M);
for i=1:M,
   for j=1:M,
      mse(i,j)=1+[b0(i) b1(j)]*Phiff*[b0(i); b1(j)]-2*[b0(i) b1(j)]*phifd;
   end
end
sp_fig(1,6,6);
set(gca,'position',[.2 .15 .75 .75]);
set(gca,'fontname','times','fontsize',14);
v=[.05 .15 .4 .8 1.8];
[c,h]=contour(b0,b1,mse,v,'g'); grid;
clabel(c);
set(h,'linewidth',1.2);
xlabel('b_0'); ylabel('b_1');

% Plot the ideal weight track.
b0=[1; -2.75]; u=.05; K=50;
k=[0:K-1];
b=bopt*ones(1,K)+(b0-bopt)*(1-2*u).^k;
line(b(1,:),b(2,:),'color','b','marker','o');

% Plot the LMS weight track.
b0=[1; -2.75]; u=.05; K=350;
k=[0:K-1];
d=sqrt(2)*sin(2*pi*k/12);
f=[0 d(1:K-1)];
[y,b]=lms_filter(b0,u,d,f,1);
line(b(1,:),b(2,:),'color','r','marker','*');
% Finish the plot.
title('Ideal and LMS covergence; u=0.05.');
text(1.07,-2.8,'b(0)');
axis square

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?