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

📄 make_plot.m

📁 大名鼎鼎赫蒙.西金的经典著作《自适应信号处理》(第4版)对应的仿真实验程序和课后习题详细解答。适合研究生学习或工程技术人员参考!
💻 M
字号:
function make_plot(v, w, rp, Nlevs, xlim, ylim, str1, str2)

% function make_plot(w, v, rp, Nlevs, xlim, ylim)

r0 =  1;
r1 = -(rp.a1/(1+rp.a2));
R  =  [r0 r1; r1 r0];
wo = [-rp.a1; -rp.a2];

% set limits on plotting and determine grid
res   = 0.1;
xl=max([xlim ylim]); yl=xl;
x_ind =  -xl:res:xl;    V1 = x_ind(ones(length(x_ind),1), :);
y_ind = [-yl:res:yl]';  V2 = y_ind(:, ones(length(y_ind),1));

Jv    = rp.Jmin + rp.lam1*V1.^2 + rp.lam2*V2.^2;	% calculate error surface wrt v

for i=1:length(x_ind),
     for j=1:length(y_ind),
      wb=[x_ind(i); y_ind(j)];
      Jw(j,i) = rp.Jmin + (wb-wo)'*R*(wb-wo);
   end
end

% determine values for first Nlevs contours (for given n)
levsv  = rp.lam1*v(1,1:Nlevs).^2 + rp.lam2*v(2,1:Nlevs).^2+rp.Jmin;

% do the plotting
figure(1)
p1_h=plot(v(1,:), v(2,:),'linewidth',2);
xlabel('v_1'); ylabel('v_2'); hold on;
contour(V1(1,:), V2(:,1), flipud(Jv), levsv,'k'); hold off
set(gca,'xlim',[-xlim xlim])
set(gca,'xlim',[-ylim ylim])
set(get(gca,'title'),'string',str1);

figure(2)
p2_h=plot(w(1,:), w(2,:),'linewidth',2);
xlabel('w_1'); ylabel('w_2'); hold on;
contour(x_ind, y_ind, Jw, levsv,'k'); hold off
set(get(gca,'title'),'string',str2);

% note that Jw did not need flipping - this was taken care of by the 
% index shuffle in the line that assigns values to Jw in the double
% loop up above

if nargin > 5,
   for i=1:2,
      figure(i)
      set(gca, 'Xlim', [-xlim xlim])
      set(gca, 'Ylim', [-ylim ylim])
      line([-xlim xlim], [0 0])
      line([0 0], [-ylim ylim]) 
      end
end

⌨️ 快捷键说明

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