pcafn.m

来自「利用ICA变换进行人脸检测,是一种新的人脸检测方法」· M 代码 · 共 35 行

M
35
字号
%function [U,R,E] = pcaFn(B);%%Principal components the normal way. Data in columns of B.%U is a matrix containing the principal component eigenvectors in %     its columns.%R is a matrix containing the principal component representations in its%     rows. Each row is the representation for the corresponding column %     of B. %E is the vector of eigenvaules corresponding to the eigenvectors in U.function [U,R,E] = pcaFn(B);%Read data into columns of B;%B = datamat';[N,P] = size(B);%********subtract meanmb=mean(B');B=B-(ones(P,1)*mb)';%********Find eigenvectors vi of BB' (NxN)[V,D] = eig (1/(P-1)*(B*B'));%********Sort eigenvectorseigvalvec = max(D);[seigvals, index] = sort(eigvalvec); % sort goes low to highVsort = V(:,[fliplr(index)]);U=Vsort;length = sqrt (sum (U.^2));U = U ./ (ones(N,1) * length);R = B'*U;E = fliplr(seigvals);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?