📄 sortem2.m
字号:
% James Javurek-Humig (3/15/05)%INPUTS: % matrix containing eigenvectors in its columns (vectors)% matrix containing the corresponding eigenvalues in a diagonal matrix% (values)%The two matricies are sorted from largest to smallest according to the%eigenvalue matrix.%RETURNS:% matrix containing the sorted eigenvectors% diagonal matrix containing the corresponding eigenvalues%This will give the same result as Matthew Dailey's sortem.m, but is much%faster for those who are worried about computational time.function [vectors values] = sortem2(vectors, values)%this error message is directly from Matthew Dailey's sortem.mif nargin ~= 2 error('Must specify vector matrix and diag value matrix')end;vals = max(values); %create a row vector containing only the eigenvalues[svals inds] = sort(vals,'descend'); %sort the row vector and get the indiciesvectors = vectors(:,inds); %sort the vectors according to the indicies from sortvalues = max(values(:,inds)); %sort the eigenvalues according to the indicies from sortvalues = diag(values); %place the values into a diagonal matrix
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -