1 / 4

7.5 特征值问题的若干 Matlab 函数文件

7.5 特征值问题的若干 Matlab 函数文件. 7.5.1 幂法的 Matlab 函数文件. 7.5.2 反幂法的 Matlab 函数文件. 7 .5.3 QR 算法的 Matlab 函数文件. 7.5.1 幂法的 Matlab 函数文件 function[z,m]=power_m(A,max_it,tol) [n,nn]=size(A);z=ones(n,1); it=0;error=100;

tory
Télécharger la présentation

7.5 特征值问题的若干 Matlab 函数文件

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 7.5 特征值问题的若干Matlab函数文件 7.5.1 幂法的Matlab函数文件 7.5.2 反幂法的Matlab函数文件 7.5.3 QR算法的Matlab函数文件

  2. 7.5.1 幂法的Matlab函数文件 function[z,m]=power_m(A,max_it,tol) [n,nn]=size(A);z=ones(n,1); it=0;error=100; disp(‘it m z(1) z(3) z(4) z(5)’)%该文件用于不超过5阶的矩阵。 while it <max_it&error>tol w=A*z;ww=abs(w); [k,kk]=max(ww);%kk为ww最大元素的标号。 m=w(kk); %特征值的近似值。 z=w/w(kk); %特征向量的近似值。 out=[it+1 m ];disp(out)

  3. 7.5.2 反幂法的Matlab函数文件 function[z,m]=invpower(A,max_it,tol) [n,nn]=size(A);z=ones(n,1);it=0;error=100; [L,U]=lu_factor(A); while it<max_it&error>tal w=lu_solve(L,U,z);ww=abs(w);[k,kk]=max(ww); m=( *z)/( *w);z=w/w(kk); out=[it+1 m ];disp(out) error=norm(A*z-m*z); it=it+1; end Error=norm(A*z-m*z); it=it+1; End error

  4. 7.5.3 QR算法的Matlab函数文件 function[Q,R]=qr_factor(A) % 矩阵A的QR分解。 [n,nn]=size(A);R=A;Q=eye(n); for k=1:n-1 x=zeros(n,1);x(k:n,1)=R(k:n,k); g=norm(x);v=x;v(k)=x(k)+g; s=norm(v);w=v/s;u=2* *w; R=R-w* ;Q=Q-2*Q*w* ; end function e=qr_eig(A,max) % 用QR算法求矩阵A的特征值。 for i=1:max [Q,R]=qr_factor(A); A=R*Q; end e=diag(A)

More Related