01.function y = pca(mixedsig)
02.
03.%程序说明:y = pca(mixedsig),程序中mixedsig为 n*T 阶混合数据矩阵,n为信号个数,T为采样点数
04.% y为 m*T 阶主分量矩阵。
05.% n是维数,T是样本数。
06.
07.if nargin == 0
08. error('You must supply the mixed data as input argument.');
09.end
10.if length(size(mixedsig))>2
11. error('Input data can not have more than two dimensions. ');
12.end
13.if any(any(isnan(mixedsig)))
14. error('Input data contains NaN''s.');
15.end
16.
17.%——————————————去均值————————————
18.meanValue = mean(mixedsig')';
19.[m,n] = size(mixedsig);
20.%mixedsig = mixedsig - meanValue*ones(1,size(meanValue)); %当数据本身维数很大时容易出现Out of memory
21.for s = 1:m
22. for t = 1:n
23. mixedsig(s,t) = mixedsig(s,t) - meanVal