function l = rqrtz(A,M)
%QR算法求矩阵全部特征值
%已知矩阵:A
%迭代步数:M
%求得的矩阵特征值:l
A = hess(A);
for i=1:M
N = size(A);
n = N(1,1);
u = A(n,n);
[q,r]=qr(A-u*eye(n,n));
A = r*q+u*eye(n,n);
l = diag(A);
end
------------------------------------
A=[0 5 0 0 0 0;1 0 4 0 0 0;0 1 0 3 0 0;0 0 1 0 2 0;0 0 0 1 0 1;0 0 0 0 1 0]
A =
0 5 0 0 0 0
1 0 4 0 0 0
0 1 0 3 0 0
0 0 1 0 2 0
0 0 0 1 0 1
0 0 0 0 1 0
>> rqrtz(A,50)
ans =
-3.2030
3.2030
-1.8837
1.8837
-0.6167
0.6167
>> eig(A)
ans =
-3.3243
3.3243
-1.8892
-0.6167
1.8892
0.6167
看matlab帮助文件,里边都有例程,电脑没有安装matlab,懒得安装了,但是我知道帮助文件里有这个例子