2017-04-07 144 views
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的經驗,在這個應用程序中找不到任何好的教程。生成用於訓練頻譜的特徵向量是否最好,然後與測試頻譜進行比較?本文的感謝

enter image description here

+0

您使用的是哪種應用程序? – m7913d

+0

對於矩陣(posx,posy,spectrum)中的每個元素,確定上面ya和yb光譜的貢獻以及最可能的光譜(即ya或yb) – 2one

回答

0

3.3節是資料:https://brage.bibsys.no/xmlui//bitstream/handle/11250/2371385/12296_FULLTEXT.pdf?sequence=1&isAllowed=y

「PCA本身不是一種分類方法,但這是基於其吸收光譜屬於哪種材料PCA可以在知識來完成。然而,作爲分類工具使用,爲此,需要訓練數據,對訓練數據執行PCA,並根據訓練數據投射一些測試數據,這就是所謂的PCA分解「。

所以我認爲我可以用上面的代碼作爲起點。