• MATLAB 的ICEEMDAN分解代码实现


    0、前言

            本文讲解ICEEMDAN分解方法,并分享代码。

    1、ICEEMDAN实现

             下面为主函数部分:

    1. ecg=data;%data为待分解的一个信号数据,请替换为自己数据就行
    2. %% 参数设置
    3. Nstd = 0.2;
    4. NR = 1;
    5. MaxIter = 5000;
    6. %% ICEEMDAN
    7. [modes]=iceemdan(ecg,Nstd,NR,MaxIter,1);%iceemdan
    8. modes=modes';
    9. t=1:length(ecg);
    10. [a b]=size(modes);
    11. figure;
    12. subplot(a+1,1,1);
    13. plot(t,ecg);% the ECG signal is in the first row of the subplot
    14. ylabel('original')
    15. set(gca,'xtick',[])
    16. title('ICEEMDAN')
    17. axis tight;
    18. for i=2:a
    19. subplot(a+1,1,i);
    20. plot(t,modes(i-1,:));
    21. ylabel (['IMF ' num2str(i-1)]);
    22. set(gca,'xtick',[])
    23. xlim([1 length(ecg)])
    24. end
    25. subplot(a+1,1,a+1)
    26. plot(t,modes(a,:))
    27. ylabel(['IMF ' num2str(a)])
    28. xlim([1 length(ecg)])
    29. xlabel('样本点')

     子函数iceemdan的代码:

    1. function [modes]=iceemdan(x,Nstd,NR,MaxIter,SNRFlag)
    2. % The current is an improved version, introduced in:
    3. %[1] Colominas MA, Schlotthauer G, Torres ME. "Improve complete ensemble EMD: A suitable tool for biomedical signal processing"
    4. % Biomedical Signal Processing and Control vol. 14 pp. 19-29 (2014)
    5. %The CEEMDAN algorithm was first introduced at ICASSP 2011, Prague, Czech Republic
    6. %The authors will be thankful if the users of this code reference the work
    7. %where the algorithm was first presented:
    8. %[2] Torres ME, Colominas MA, Schlotthauer G, Flandrin P. "A Complete Ensemble Empirical Mode Decomposition with Adaptive Noise"
    9. % Proc. 36th Int. Conf. on Acoustics, Speech and Signa Processing ICASSP 2011 (May 22-27, Prague, Czech Republic)
    10. %Author: Marcelo A. Colominas
    11. %contact: macolominas@bioingenieria.edu.ar
    12. %Last version: 25 feb 2015
    13. desvio_x=std(x);
    14. x=x/desvio_x;
    15. [a,b]=size(x);
    16. temp=zeros(b,1);
    17. modes=zeros(b,1);
    18. aux=zeros(a,b);
    19. for i=1:NR
    20. white_noise{i}=randn(size(x));%creates the noise realizations
    21. end;
    22. for i=1:NR
    23. modes_white_noise{i}=emd(white_noise{i},'display',0);%calculates the modes of white gaussian noise
    24. end;
    25. % save interval modes_white_noise
    26. for i=1:NR %calculates the first mode
    27. xi=x+Nstd*modes_white_noise{i}(:,1)'/std(modes_white_noise{i}(:,1));
    28. [temp, o, it]=emd(xi,'MaxNumIMF',1,'SiftMaxIterations',MaxIter,'display',0);
    29. aux=aux+(xi-temp')/NR;% nnnnnnnnnnnnnnnnJub局部包络
    30. end;
    31. modes= (x-aux)'; %saves the first mode
    32. medias = aux; % r1
    33. k=1;
    34. aux=zeros(a,b);
    35. es_imf = min(size(emd(medias(1,:),'SiftMaxIterations',MaxIter,'display',0)));
    36. while es_imf>1 %calculates the rest of the modes
    37. for i=1:NR
    38. tamanio=size(modes_white_noise{i});
    39. if tamanio(2)>=k+1
    40. noise=modes_white_noise{i}(:,k+1);
    41. if SNRFlag == 2
    42. noise=noise/std(noise); %adjust the std of the noise
    43. end;
    44. noise=Nstd*noise;
    45. try
    46. [temp,o,it]=emd(medias(1,:)+std(medias(1,:))*noise','MaxNumIMF',1,'SiftMaxIterations',MaxIter,'display',0);
    47. catch
    48. temp=emd(medias(1,:)+std(medias(1,:))*noise','MaxNumIMF',1,'SiftMaxIterations',MaxIter,'display',0);
    49. end;
    50. else
    51. try
    52. [temp, o, it]=emd(medias(1,:),'MaxNumIMF',1,'SiftMaxIterations',MaxIter,'display',0);
    53. catch
    54. temp=emd(medias(1,:),'MaxNumIMF',1,'SiftMaxIterations',MaxIter,'display',0);
    55. end;
    56. end;
    57. aux=aux+(medias(1,:)+std(medias(1,:))*noise'-temp')/NR;% r2 r3 r...
    58. end;
    59. modes=[modes (medias(1,:)-aux)'];
    60. medias = aux;
    61. aux=zeros(size(x));
    62. k=k+1;
    63. es_imf = min(size(emd(medias(1,:),'SiftMaxIterations',MaxIter,'display',0)));
    64. end;
    65. modes = [modes (medias(1,:))'];
    66. modes=modes*desvio_x;

            上述代码可以直接运行,实现信号分解。

  • 相关阅读:
    Python机器学习从0到1:从十余行代码看机器学习的套路(附零基础学习资料)
    【马蹄集】—— 百度之星 2023
    剑指offer--调整数字顺序使奇数位于偶数前面
    uniapp地图点击获取位置
    2022年川渝网络与信息安全职业技能竞赛-个人初赛writeup
    vlan,每个接口都配了对应的trunk或hybrid并且放行,但还是ping不通,三个都互相不通
    C++学习:数据的存储、作用域、链接
    npmjs官网(查询依赖包)
    flask框架初学-06-对数据库的增删改查
    Fastdfs图片上传 配置Fastdfs在linux------基于SpringBoot
  • 原文地址:https://blog.csdn.net/m0_61363749/article/details/126143868