MATLAB中的特征值 [英] Eigenvalues in MATLAB

查看:199
本文介绍了MATLAB中的特征值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MATLAB中,当我对对称矩阵运行命令[V,D] = eig(a)时,最大特征值(及其关联的矢量)位于最后一列.但是,当我使用非对称矩阵运行它时,最大特征值在第一列中.

In MATLAB, when I run the command [V,D] = eig(a) for a symmetric matrix, the largest eigenvalue (and its associated vector) is located in last column. However, when I run it with a non-symmetric matrix, the largest eigenvalue is in the first column.

我正在尝试计算特征向量中心性,这要求我计算与最大特征值相关的特征向量.因此,最大特征值出现在两个不同的位置这一事实使我很难找到解决方案.

I am trying to calculate eigenvector centrality which requires that I take the compute the eigenvector associated with the largest eigenvalue. So the fact that the largest eigenvalue appears in two separate places it makes it difficult for me to find the solution.

推荐答案

您只需要在D中找到最大特征值的索引,就可以使用函数

You just have to find the index of the largest eigenvalue in D, which can easily be done using the function DIAG to extract the main diagonal and the function MAX to get the maximum eigenvalue and the index where it occurs:

[V,D] = eig(a);
[maxValue,index] = max(diag(D));  %# The maximum eigenvalue and its index
maxVector = V(:,index);           %# The associated eigenvector in V

注意:正如 woodchips指出的,您对于非对称矩阵,可以具有复杂的特征值.在复杂输入X上进行操作时, MAX 函数使用复数max(abs(X))的大小.对于大小相等的元素,使用相角max(angle(X)).

NOTE: As woodchips points out, you can have complex eigenvalues for non-symmetric matrices. When operating on a complex input X, the MAX function uses the magnitude of the complex number max(abs(X)). In the case of equal magnitude elements, the phase angle max(angle(X)) is used.

这篇关于MATLAB中的特征值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆