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

📄 e6422exer4.m

📁 these code are about adaptive filter.
💻 M
字号:
%
%  Example 8: Generating Quadratic Surfaces .... 
%  
%   J = x'Rx + A'x + C       R is a 2X2 correlation matrix
%                            A, x are 2X1 vectors ---  C is a constant
%
%   surface minimum occurs at, gradient = 2Rx + A  =  0 ....
%

clear all;

R = [0.5 0.25 ; 0.25 0.5 ] ;  A  = [-60 -60]' ; C = 1.0 ;

xo = -inv(R)*A/2  ;

for jj = 1:100
   for kk = 1:100
      
      x1 = (jj-50)*100/50 ;
      x2 = (kk-50)*100/50 ;

   x = [x1 x2]' ;
   J(jj,kk) = x'*R*x + A'*x + C ;
   x1mat(jj,kk) = x1  ;
   x2mat(jj,kk) = x2  ;
   
  end;
end ;

%
% .... A 3d-plot and a contour plot of quadratic surface J ....
%

figure(1); mesh(x1mat,x2mat,J) ; 
xlabel('x_1-new');
ylabel('x_2-new');
title('Original Quadratic Surface, J') ;

figure(2); contour(x1mat,x2mat,J,10) ; grid ;

xlabel('x_1');
ylabel('x_2');
title('Original Quadratic Surface, J') ;

%
% .... Shifted quadratic surface J ....
%

for jj = 1:100
   for kk = 1:100
      
      x1 = (jj-50)*100/50 ;
      x2 = (kk-50)*100/50 ;

   x = [x1 x2]' + xo ;
   J(jj,kk) = x'*R*x + A'*x + C ;
   x1mat(jj,kk) = x1  ;
   x2mat(jj,kk) = x2  ;
   
  end;
end ;

figure(3); contour(x1mat,x2mat,J,10) ; grid ;

xlabel('x_1');
ylabel('x_2');
title('Shifted Quadratic Surface') ;

%
% .... Shifted and Rotated quadratic surface J ....
%

[vv, dd] = eig(R) ;

for jj = 1:100
   for kk = 1:100   
      xNew = vv*[x1mat(jj,kk) x2mat(jj,kk)]'  ;
      x1matR(jj,kk) = xNew(1)  ;
      x2matR(jj,kk) = xNew(2)  ;
   end;
end ;

figure(4); contour(x1matR,x2matR,J,30) ; grid ;

xlabel('x_1-new');
ylabel('x_2-new');
title('Shifted and Rotated Quadratic Surface') ;

%
% .... Shifted, Rotated and Scaled quadratic surface J ....
%

%figure(5); contour(x1matR*sqrt(dd(2,2)),x2matR*sqrt(dd(1,1)),J,30) ; grid ;
% note: the above line is in error. Following line is correct ...

figure(5); contour(x1matR/sqrt(dd(2,2)),x2matR/sqrt(dd(1,1)),J,30) ; grid ;
axis([-160 160 -160 160]) ;

xlabel('x_1-new');
ylabel('x_2-new');
title('Shifted, Rotated and Scaled Quadratic Surface') ;

%
%  Note : that the contours are now circles ....!!!!
%

⌨️ 快捷键说明

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