www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/LargestEigenvaluePairsOfSparseMatrixExample.m

    %% Largest Eigenvalue Pairs of Sparse Matrix
% west0479 is a real-valued 479-by-479 sparse matrix with both real and
% complex pairs of conjugate eigenvalues. |eig| computes all 479
% eigenvalues. |eigs| easily picks out the largest magnitude eigenvalues.
%%
% This plot shows the 8 largest magnitude eigenvalues of west0479 as
% computed by |eig| and |eigs|.

% Copyright 2015 The MathWorks, Inc.

load west0479
d = eig(full(west0479));
dlm = eigs(west0479,8);
[dum,ind] = sort(abs(d));
plot(dlm,'k+')
hold on
plot(d(ind(end-7:end)),'ks')
hold off 
legend('eigs(west0479,8)','eig(full(west0479))')