⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fg_09_07.m

📁 英文书《Digital Signal Processing with Examples in MATLAB》附带的MATLAB实例
💻 M
字号:
% fg_09_07    MSE contour plot w/ RLS & LMS weight tracks.
N=140; m=1;
phi=cos(2*pi*[0:12]/12);
Phiff=[phi(1) phi(2); phi(2) phi(1)];
phifd=[phi(m+1); phi(m+2)];
bopt=Phiff\phifd;
% Plot the contours.
db=1.99;
b0=linspace(bopt(1)-db,bopt(1)+db,N);
b1=linspace(bopt(2)-db,bopt(2)+db,N);
mse=zeros(N,N);
for i=1:N,
   for j=1:N,
      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,'fontsize',16);
v=[.05 .15 .4 .8 1.8];
[c,h]=contour(b0,b1,mse,v,'k'); grid;
clabel(c);
set(h,'linewidth',1.2);
xlabel('b_0'); ylabel('b_1');
% Initialize for tracks.
b0=[1; -2.75];

% Plot the RLS weight track.
u=.02; alpha=.2;
K=150;
k=[0:K-1];
d=sqrt(2)*sin(2*pi*k/12);
f=[0 d(1:K-1)];
[y,b]=rls_filter(b0,u,alpha,d,f);
line(b(1,:),b(2,:),'color','b','marker','o');
fprintf('RLS:%6.3f%6.3f%9.3f%7.3f\n',u,alpha,b(:,K));

% Plot the LMS weight track.
u=.05;
K=300;
k=[0:K-1];
d=sqrt(2)*sin(2*pi*k/12);
f=[0 d(1:K-1)];
b0=[1; -2.75];
[y,b]=lms_filter(b0,u,d,f,1);
line(b(1,:),b(2,:),'color','r','marker','*');
fprintf('LMS:%6.3f%15.3f%6.3f\n',u,b(:,K));
% Finish the plot.
title('RLS (K=300) and LMS (K=150) covergence');
text(1.07,-2.8,'b(0)');

% Plot lines thru bopt.
line([bopt(1) bopt(1)],[-5 5],'color','g');
line([-5 5],[bopt(2) bopt(2)],'color','g');
axis square

⌨️ 快捷键说明

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