0
我有一個光譜(波長(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的經驗,在這個應用程序中找不到任何好的教程。生成用於訓練頻譜的特徵向量是否最好,然後與測試頻譜進行比較?本文的感謝
您使用的是哪種應用程序? – m7913d
對於矩陣(posx,posy,spectrum)中的每個元素,確定上面ya和yb光譜的貢獻以及最可能的光譜(即ya或yb) – 2one