📄 informax.m
字号:
clear all
b1=wavread('1.wav');
b2=wavread('2.wav');
b1=b1(1:80000,:);
b2=b2(1:80000,:);
b=[b1';b2'];
sources=b;
[N,P]=size(sources); %P为采样点数,N为信号个数
permute=randperm(P); %产生一个置换矩阵
s=sources(:,permute);a=rand(N);
% a=[1 2;1 1]; %混合矩阵,或a=rand(N)
x=a*s; %置换的输入信号混合
mixes=a*sources; %无置换的混合信号
%如果直接加载混合信号mixes=readsounds(['minx2';'mix1'])
%------预白化数据-----------------------
mx=mean(mixes');c=cov(mixes');
x=x-mx'*ones(1,P); %去均值
wz=2*inv(sqrtm(c)); %计算解相关矩阵
x=wz*x;
%--------各个初始值的选择-----------------
w=[1 1;1 2]; %解混矩阵初始化也可为w=eye(N)或 w=rand(M,N)
M=size(w,2); %一般情况M=N
sweep=0;
Id=eye(M);
%-------------下面为4种情况的学习过程----------------------------
L=0.01;B=30; %2个信号
%L=0.001;B=30;sep %大于2个信号
%L=0.0001;B=30;sep %大于100个信号
%L=0.005;B=30;forI=1:10000,sep ;end;
sweep=sweep+1;t=1;
noblocks=fix(P/B);
BI=B*Id;
for t=t:B:t-1+noblocks*B
u=w*x(:,t:t+B-1);
w=w+L*(BI+(1-2*(1./(1+exp(-u))))*u')*w;
end
w=w*wz;
y=w*x;y1=y(1,:);y2=y(2,:);subplot(2,1,1);plot(y1);subplot(2,1,2);plot(y2);figure(2)
x1=x(1,:);x2=x(2,:);subplot(2,1,1);plot(x1);subplot(2,1,2);plot(x2);figure(3)
mixes1=mixes(1,:);mixes2=mixes(2,:);subplot(2,1,1);plot(mixes1);subplot(2,1,2);plot(mixes2);figure(4)
y=w*mixes;y1=y(1,:);y2=y(2,:);subplot(2,1,1);plot(y1);subplot(2,1,2);plot(y2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -