FastICA实施.. Matlab

时间:2019-11-27 03:19:04

标签: matlab statistics signal-processing

我一直在使用MatLab进行FastICA算法实现。目前,代码无法像id一样分隔信号。我想知道这里是否有人可以给我一些建议,以解决该问题?

disp('*****Importing Signals*****');

s = [1,30000];

[m1,Fs1] = audioread('OSR_us_000_0034_8k.wav', s);
[f1,Fs2] = audioread('OSR_us_000_0017_8k.wav', s);

ss = size(f1,1);
n = 2; 

disp('*****Mixing Signals*****');

A = randn(n,n); %developing mixing matrix 

x = A*[m1';f1']; %A*x

m_x = sum(x, n)/ss; %mean of x 

xx = x - repmat(m_x, 1, ss); %centering the matrix 

c = cov(x');
sq = inv(sqrtm(c)); %whitening the data 
x = c*xx;

D = diff(tanh(x)); %setting up newtons method 
SD = diff(D);

disp('*****Generating Weighted Matrix*****');

w = randn(n,1); %Random weight vector
w = w/norm(w,2); %unit vector
w0 = randn(n,1);
w0 = w0/norm(w0,2); %unit vector

disp('*****Unmixing Signals*****');

while abs(abs(w0'*w)-1) > size(w,1)

   w0 = w;
   w = x*D(w'*x) - sum(SD'*(w'*x))*w;  %perform ICA
   w = w/norm(w, 2);

end

disp('*****Output After ICA*****');

sound(w'*x); % Supposed to be one of the original signals

subplot(4,1,1);plot(m1); title('Original Male Voice'); 
subplot(4,1,2);plot(f1); title('Original Female Voice'); 
subplot(4,1,4);plot(w'*x); title('Post ICA: Estimated Signal');

%figure;
%plot(z); title('Random Mixed Signal');

%figure;
%plot(100*(w'*x)); title('Post ICA: Estimated Signal');

1 个答案:

答案 0 :(得分:0)

您的协方差矩阵c是2 x 2,因此您不能使用它。您必须将信号多次与随机数混合才能到达任何地方,因为您必须具有不同通道共有的一些信号(m1)。我无法遵循您的fast-ICA代码,但这是一个PCA示例:

url = {'https://www.voiptroubleshooter.com/open_speech/american/OSR_us_000_0034_8k.wav';...
    'https://www.voiptroubleshooter.com/open_speech/american/OSR_us_000_0017_8k.wav'};
%fs = 8000;
m1 = webread(url{1});
m1 = m1(1:30000);
f1 = webread(url{2});
f1 = f1(1:30000);
ss = size(f1,1);
n = 2; 
disp('*****Mixing Signals*****');
A = randn(50,n); %developing mixing matrix 
x = A*[m1';f1']; %A*x
[www,comp] = pca(x');
sound(comp(:,1)',8000)