哪位好心的朋友帮忙用matlab 计算一下下面这个矩阵的最大特征值和其对应的特征向量?

2025-01-19 02:59:53
推荐回答(1个)
回答1:

%file maxnorm.m
function t=maxnorm(a)
%the maximum element of the array
n=length(a);
t=0;
for i=1:n
if abs(a(i)/max(abs(a)))>=1
t=a(i);
end
end

%%%%把上面的文件存为maxnorm.m

%file maxtr.m
function [mt,my]=maxtr(a,eps)
%a the matrix
%eps the accept error ,you decide it
%mt the maximum eigenvalue of the matrix
%my the corresponding eigenvector of mt

n=length(a);
x0=diag(ones(n));
k=1;
x=a*x0;
while norm(x-x0)>eps
k=k+1;
q=x;
y=x/maxnorm(x);
x=a*y;
x0=q;
end
mt=maxnorm(x);
my=y;

%%%%把上面的文件存为maxtr.m

运行:A=[1,1/2,1/3,1/3,2;
2,1,1/2,1/2,4
3,2,1,1,6
3,2,1,1,6;
1/2,1/4,1/6,1/6,1]

[mt,my]=maxtr(A,0.0001)

运行结束后结果:

mt =

5.0133

my =

0.3146
0.5628
1.0000
1.0000
0.1573