clc
clear;
t=0:0.0001:1-0.0001;
s1=sin(2*pi*10*t);
s2=sin(2*pi*50*t);
s3=rand(1,length(t))-0.5;
X=[0.3763 2.0243 -1.3216;-0.2270 -2.3595 -0.6361;-1.1489 -0.5100 0.3179]*[s1;s2;s3]+0*randn(3,length(t));
C=X*X';
[E,D]=eig(C);
V=E*D^(-0.5)*E';
z=V*X;
w=orth(randn(size(X,1)));%正交规范化一个和X的列有同样维数大小的随机数组
ww=w;
%%
wold=zeros(size(w));
epsilon=0.000000001;
maxNumIterations=100;
numSamples=length(X(1,:));%X第一行的长度
for i=1:size(z,1)
for round=1:maxNumIterations+1
if round==maxNumIterations+1
fprintf('经过 %d 步迭代后,并未出现收敛\r',maxNumIterations);
end
w(:,i)=mean((z*(((w(:,i))'*z).^3)'),2)-3*mean(((w(:,i))'*z).^2)*w(:,i);
if i>1
temp=0;
for j=1:i-1
temp=(w(:,i))'*w(:,j)*w(:,j)+temp;
end
w(:,i)=w(:,i)-temp;
end
w(:,i)=w(:,i)/norm(w(:,i));
minAbs=min(abs(diag(w(:,i)'*wold(:,i))));
if (abs(1-minAbs)<epsilon)
fprintf('经过 %d 步迭代收敛\r',round)
break
end
wold(:,i)=w(:,i);
end
end
S=w'*z;
subplot(311);plot(S(1,:))
subplot(312);plot(S(2,:))
subplot(313);plot(S(3,:))