www.gusucode.com > 《模式识别与智能计算》matlab源代码 > 《模式识别与智能计算》matlab源代码/《模式识别与智能计算》部分函数的源程序/书程序/第2章/mypcacov.m
function [y1,y2]=mypcacov(varargin) if length(varargin)>1 sample=varargin{1}; test=varargin{2}; else sample=varargin; end [r1,c]=size(sample); x=cov(sample); [pc,latent]=pcacov(x); sum_latent=sum(latent); temp=0;con=0;m=0; for i=1:c if con<0.85 temp=temp+latent(i); con=temp/sum_latent; m=m+1; else break; end end pc(:,m+1:c)=[]; y1=sample*pc; y2=test*pc;