maxev.m
来自「网络分析法(ANP)的一个实现」· M 代码 · 共 33 行
M
33 行
% 求一个方阵的最大特征值及其对应的特征向量
% version 1.0
% MaxEV 函数开始
function [Max_Eigenvector,Max_Eigenvalue] = MaxEV(Matrix)
[lineCount,columeCount] = size(Matrix);
if lineCount ~= columeCount
message = '矩阵不是方阵,无法求解最大特征值及其对应的特征向量';
disp(message);
return;
end
[Eigenvector Eigenvalue] = eigs(Matrix);
% 上句执行后有如下信息出现,是为了把为零的eigenvalue去掉
% Iteration 1: a few Ritz values of the 12-by-12 matrix:
% 0
% 0
% 0
% 0
% 0
% 0
% 0
Max_Eigenvalue = Eigenvalue(1);
for i=1:1:lineCount
Max_Eigenvector(i) = Eigenvector(i,1);
end
% MaxEV 函数结束
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?