• 大小: 2KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-12-01
  • 语言: 其他
  • 标签: 432  

资源简介

完美分离各种混合音频,并且有输出功能,并且算法在分离性能上比传统算法高效,

资源截图

代码片段和文件信息

function ICAedS = fastica_3_1(MixedS)
%%%%%%%%%%%%%%%%%%%%%%%%%%  标准化  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
MixedS_mean=zeros(31);
for i=1:3
    MixedS_mean(i)=mean(MixedS(i:));
end                                        % 计算MixedS的均值

for i=1:3
    for j=1:size(MixedS2)
        MixedS(ij)=MixedS(ij)-MixedS_mean(i);
    end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%  白化  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MixedS_cov=cov(MixedS‘);                    % cov为求协方差的函数
[ED]=eig(MixedS_cov);                      % 对信号矩阵的协方差函数进行特征值分解
Q=inv(sqrt(D))*(E)‘;                        % Q为白化矩阵
MixedS_white=Q*MixedS;                      % MixedS_white为白化后的信号矩阵
IsI=cov(MixedS_white‘);                     % IsI应为单位阵            

%%%%%%%%%%%%%%%%%%%%%%%% FASTICA算法  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X=MixedS_white;                            % 以下算法将对X进行操作
[VariableNumSampleNum]=size(X);
numofIC=VariableNum;                       % 在此应用中,独立元个数等于变量个数
B=zeros(numofICVariableNum);              % 初始化列向量w的寄存矩阵B=[b1  b2  ...   bd]
for r=1:numofIC
    i=1;maxIterationsNum=100;               % 设置最大迭代次数(即对于每个独立分量而言迭代均不超过此次数)
    k=0;
    b=rand(numofIC1);                  % 随机设置b初值
    b=b/norm(b);
    %HHH=b;
    % 对b标准化 norm(b):向量元素平方和开根号
    while i<=maxIterationsNum+1
        if i == maxIterationsNum           % 循环结束处理
            fprintf(‘\n第%d分量在%d次迭代内并不收敛。‘ rmaxIterationsNum);
            break;
        end
        bOld=b;                          
        a2=1;
        t=X‘*b;
        g=t.*exp(-a2*t.^2/2);
        dg=(1-a2*t.^2).*exp(-a2*t.^2/2);
%         b=((1-u)*t‘*g*b+u*X*g)/SampleNum-mean(dg)*b;
                          % 核心公式,参见理论部分公式2.52
        ava=(X*g)/SampleNum;
        ave=mean(dg)*b;
        b=ava-ave;
        b=b-B*B‘*b; 
        b=b/norm(b);
        b0=b;
        t2=X‘*b;
        dg2=(1-a2*t2.^2).*exp(-a2*t2.^2/2);
        ave2=mean(dg2)*bOld;
        b=2*ava-ave-ave2;
        b=b-B*B‘*b;                        % 对b正交化
        b=b/norm(b); 
        k=k+1;
%         abs(abs(b‘*bOld)-1)<1e-9
        if abs(abs(b‘*b0)-1)<1e-9
           % jjjj=b;                     % 如果收敛,则
             B(:r)=b;                     % 保存所得向量b
             fprintf(‘\n第%d分量在%d次迭代。‘ rk)
             break;
             
         end
        i=i+1;        
    end
%    B(:r)=b;                                % 保存所得向量b
end
%%%%%%%%%%%%%%%%%%%%%%%%%%  ICA计算的数据复原并构图  %%%%%%%%%%%%%%%%%%%%%%%%%
ICAedS=B‘*MixedS_white;   
end% 计算ICA后的矩阵


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2753  2018-09-14 09:01  f_3_1\fastica_3_1.m

     文件       1782  2018-09-14 09:01  f_3_1\f_3_1.m

     目录          0  2018-12-26 10:22  f_3_1

----------- ---------  ---------- -----  ----

                 4535                    3


评论

共有 条评论