作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/23 12:04:29
哪位好心的朋友帮忙用matlab 计算一下下面这个矩阵的最大特征值和其对应的特征向量?
矩阵如下:
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]
急需求得这个矩阵的最大特征值和其对应的特征向量,哪位手头有matlab的好心的朋友帮忙计算一下呀?非常感谢!
哪位好心的朋友帮忙用matlab 计算一下下面这个矩阵的最大特征值和其对应的特征向量?
%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