⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apca.m

📁 Optimized scaling算法 可以用来优化选择
💻 M
字号:
function [score,loading]=apca(raw,centr,max);%	[T,P]=apca(raw,0,max);%%	The Matlab routine perform a pca analysis of the data %	%	Uses singular value decomposition (svd)% 	raw - data matrix% 	Data must exist as objects*variables%  centr=1, centering data (column by column)% 	centr=0, data is not centered%	max - max number of components to be presented %	% 	Information regarding the principal components will be given as%	PC #	Egenverdi	%var	%totvar%%	Laila Stordrange 16/10-00%[m,n]=size(raw);%	Centering the matrixgj=mean(raw);if centr==1;	raw=raw - ones(m,1)*gj;end;%	Calculation of principal componentsif n<m 	% More objects than variables    cov=(raw'*raw);	%/m-1;	   [u,s,v]=svd(cov);   temp2=(1:n)';   else   cov=(raw*raw');	%/m-1;   [u,s,v]=svd(cov);   v=raw'*v; 	% Calculate loadings      for i=1:m      v(:,i)=v(:,i)/norm(v(:,i)); %Normalize the loadings   end   temp2=(1:m)';   endtemp = (diag(s)*100)./(sum(diag(s)));ssq = [temp2 diag(s) temp cumsum(temp)];% Remove uninteresting components from the presentationinfo=zeros(max,4);for i=1:max   info(i,:)=ssq(i,:);end% Presentation of the calculated componentsdisp('	')disp('	Percent explained by the PCA model')disp('	')disp(' PC#  Eigenvalues  %Variance  %TotVar')disp(info)% Ask how many components to be madelv=max+1;while lv>max   input('How many principal components would you like to keep?');   lv=ans;end% Makes the PCA model by means of the information given aboveloading=v(:,1:lv);score=raw*loading;loading=loading';% Saving of the interesting components, only z=zeros(lv,4);for i=1:lv   z(i,:)=ssq(i,:);endinfo=z;% End      

⌨️ 快捷键说明

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