Untitled.m
资源名称:KPCA.rar [点击查看]
上传用户:nxf103
上传日期:2017-12-04
资源大小:2690k
文件大小:1k
源码类别:
能源行业(电力石油煤炭)
开发平台:
Matlab
- load x00;
- load t05;
- PCA_num=11
- %x00=[x00(1,:); x00(80,:);x00(120,:)];
- [tr,meanp,stdp] = prestd(x00');
- te = trastd(t05',meanp,stdp);
- tr=tr';
- te=te';
- trd=data(tr);
- ted=data(te);
- %[r,a]=train(kpca,tr);
- %%%%% %主元分析%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- [pc,score,latent,tsquare]=princomp(trd);
- PCA=pc(:,1:PCA_num);
- score_PCA=score(:,1:PCA_num);
- latent_PCA=diag(latent(1:PCA_num));
- %%%%% %新测试数据(故障数据)作主元分析%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- [n1,m1]=size(t15);
- PCA_Test=zeros(n1,PCA_num);
- Fault_guji=zeros(n1,m1);
- TT=zeros(1,n1);
- for i=1:n1,
- for j=1:PCA_num,
- PCA_Test(i,j)=ted(i,:)*PCA(:,j);
- ted_guji(i,:)=ted_guji(i,:)+ted(i,:)*PCA(:,j)*PCA(:,j)';
- end
- %求T2统计
- TT(i)=PCA_Test(i,:)*inv(latent_PCA)*PCA_Test(i,:)';
- %求SPE统计
- end
- ted_ee=ted-ted_guji;
- for i=1:n1,
- ted_SPE(i)=ted_ee(i,:)*ted_ee(i,:)';
- end
- figure(1);
- subplot(2,1,1);
- plot(TT);
- subplot(2,1,2);
- plot(ted_SPE);
- title('fault SPE');