Matlab:信号的主分量分析(光谱解混)
问题描述:
我有一个光谱(波长(x)对吸收(y)),它是两个信号(xa,ya)和(xb,yb)的混合。我试图用PCA(代码我在网上找到),以UNMIX的信号(X,Y):Matlab:信号的主分量分析(光谱解混)
%step 1, input data
numdata=length(data(:,1));
x=data(:,1);
y=data(:,1);
%step 2, finding a mean and subtracting
xmean=mean(x);
ymean=mean(y);
xnew=x-xmean*ones(numdata,1);
ynew=y-ymean*ones(numdata,1);
subplot(3,1,1);
plot(x,y, 'o');
title('Original Data');
%step 3, covariance matrix
covariancematrix=cov(xnew,ynew);
%step 4, Finding Eigenvectors
[V,D] = eig(covariancematrix);
D=diag(D);
maxeigval=V(:,find(D==max(D)));
%step 5, Deriving the new data set
%finding the projection onto the eigenvectors
finaldata=maxeigval'*[xnew,ynew]';
subplot(3,1,2);
stem(finaldata, 'DisplayName', 'finaldata', 'YDataSource', 'finaldata');
title('PCA 1D output ')
%we do a classification now
subplot(3,1,3);
title('Final Classification')
hold on
for i=1:size(finaldata,2)
if finaldata(i)>=0
plot(x(i),y(i),'o')
plot(x(i),y(i),'r*')
else
plot(x(i),y(i),'o')
plot(x(i),y(i),'g*')
end
end
如何最好地应用PCA输出UNMIX(Y)成组件雅和YB?我没有PCA的经验,在这个应用程序中找不到任何好的教程。生成用于训练频谱的特征向量是否最好,然后与测试频谱进行比较?本文的感谢
答
“PCA本身不是一种分类方法,但这是基于其吸收光谱属于哪种材料PCA可以在知识来完成。然而,作为分类工具使用,为此,需要训练数据,对训练数据执行PCA,并根据训练数据投射一些测试数据,这就是所谓的PCA分解“。
所以我认为我可以用上面的代码作为起点。
您使用的是哪种应用程序? – m7913d
对于矩阵(posx,posy,spectrum)中的每个元素,确定上面ya和yb光谱的贡献以及最可能的光谱(即ya或yb) – 2one