?? makbasis.txt
字號(hào):
function [W,neig] = makebasis(X)
% A = makebase(X)
%
% Function that creates the "faces space", i. e. the
% basis of the space created throught the eigenvectors
% of the covariance matrix of the population matrix.
%
% X = Population matrix (as described in function
% makepop().
%
% A = Orthogonal basis of the face space.
% Covariance matrix:
% ['Computing the covariance matrix of X (Cx)...']
miu=mean(X,2);
A=X-repmat(miu,1,size(X,2));
S=A'*A;
% S=A*A';
% ['Computing the eigenfaces and eigenvalues of Cx...']
[V,D] = eig(S); % D = diagonal matrix with the eigenvalues
% V = matrix in witch eacj column is the
% respective eigenfaces:
% Cx*V = V*D.
V=A*V;
% neig=size(X,2);
neig=rank(S);
% ['Sorting the eigenvectors with respect to the decreasing order of the eigenvalues...']
eigenvalues = diag(D);
[eigenvalues, index] = sort(eigenvalues);
sizeV=size(V,2);
W=zeros(size(V));
for c=1:sizeV,
eigenvalues_sort(c) = eigenvalues(sizeV-c+1);
W(:,c) = V(:,index(sizeV-c+1)); % A is the eigenvector matrix sorted with respect to the eigenvalues.
W(:,c)=W(:,c)/norm(W(:,c));
end
eigenvalues=eigenvalues_sort';
return
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -