sortem2.m

来自「人脸识别matlab程序 with a principal component」· M 代码 · 共 30 行

M
30
字号
% 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 + =
减小字号Ctrl + -
显示快捷键?