1、functio艘绒庳焰n[coeff,score,latent,tsquare]=princomp(x,econFlag)%PRINC晦倘佳鳎OMPPrincipalComponentsAnalysis(PCA)fromrawdata.%COEFF=PRINCOMP(X)performsprincipalcomponentsanalysisontheN-by-P%datamatrixX,andreturnstheprincipalcomponentcoefficients,also
2、PRINCOMPcentersXbysubtractingoffcolumnmeans,butdoesnotrescalethe艘早祓胂columnsofX.ToperformPCAwithstandardizedvariables,i.e.,basedoncorrelations,usePRINCOMP(ZSCORE(X)).ToperformPCA directlyonacovarianceorcorrelationmatrix,usePCACOV.
3、[COEFF,SCORE]=PRINCOMP(X)returnstheprincipalcomponentscores,i.e.,therepresentationofXintheprincipalcomponentspace.RowsofSCOREcorrespondtoobservations,columnstocomponents.
4、对于这个饱和函数。 delta=20; kk=1/delta; if abs(s)>delta; sat=sign(s); else sat=kk*s;这个是我在M文件S函数中的表达。
5、real_T kk,delta;real_T sat(real_T x){if (fabs(x)>delta) return (sign(x)); else return (kk*x); };
6、endendEnforceasignconventiononthecoefficients--thelargestelementineachcolumnwillhaveapositivesign.
7、[~,maxind]=max(abs(coeff),[],1);d=size(coeff,2);colsign=sign(coeff(maxind+(0:p:(d-1)*p)));coeff=bsxfun(@times,coeff,colsign);ifnargout>1score=bsxfun(@times,score,colsign);end