First, the way to obtain the code
Get the code 1: by subscribing to the paid column of purple Pole Shenguang blog, you can get this code with payment voucher, private letter bloggers.
Access code 2: Open CSDN membership through the homepage of CSDN blog, and the code can be obtained by payment voucher and private letter bloggers.
[digital signal] based on MATLAB CEEMD digital signal decomposition [matlab source code 1383]
Note: For CSDN membership, only one code can be obtained free of charge (valid within three days from the date of opening); Subscribe to the paid column of purple Pole Shenguang blog, you can get 2 copies of the code for free (valid for three days from the subscription date);
Two, some source code
clc; clear; close all t=1/1000:1/1000:1;
x=sin(20*pi*t)+sin(40*pi*t)+2*sin(60*pi*t);
imf=ceemd(x,0.02.50.2); %----------------IMF show ---------------- figure(1);
imfn=imf';
n=size(imfn,1);
subplot(n,1.1); plot(t,x); % Original signal ylabel('Raw signal'.'fontsize'.12.'fontname'.'Song in Chinese Language');
for n1=1:n- 1
subplot(n,1,n1+1); plot(t,imfn(n1,:)); % the IMF component ylabel (['IMF' int2str(n1)]);
end
figure(2);
imfn=imf';
n=size(imfn,1);
subplot(n,1.1);
[f,z]=COMPUTE_FFT(t,x);
plot(f(1:50),z(1:50)); % Original signal ylabel('Raw signal'.'fontsize'.12.'fontname'.'Song in Chinese Language');
for n1=1:n- 1
subplot(n,1,n1+1);
[f,z]=COMPUTE_FFT(t,imfn(n1,:));
plot(f(1:50),z(1:50)); % the IMF component ylabel (['IMF' int2str(n1)]);
end
ylabel('RES');
xlabel('time \ itt/s'.'fontsize'.12.'fontname'.'Song in Chinese Language');
% Y: Inputted data;
% Nstd: ratio of the standard deviation of the added noise and that of Y;
% NE: Ensemble member being used
% TNM: total number of modes (not including the trend)
%
function allmode=ceemd(Y,Nstd,NE,TNM)
% find data length
xsize=length(Y);
dd=1:1:xsize;
% Nornaliz data
Ystd=std(Y);
Y=Y/Ystd;
% Initialize saved data
TNM2=TNM+2;
for kk=1:1:TNM2,
for ii=1:1:xsize,
allmode(ii,kk)=0.0;
end
end
for iii=1:1:NE
% adding noise
for i=1:xsize,
temp=randn(1.1)*Nstd;
X1(i)=Y(i)+temp;
X2(i)=Y(i)-temp;
end
% sifting X1
xorigin = X1;
xend = xorigin;
% save the initial data into the first column
for jj=1:1:xsize
mode(jj,1) = xorigin(jj);
end
nmode = 1;
while nmode <= TNM,
xstart = xend;
iter = 1;
while iter<=5,
[spmax, spmin, flag]=extrema(xstart);
upper= spline(spmax(:,1),spmax(:,2),dd);
lower= spline(spmin(:,1),spmin(:,2),dd);
mean_ul = (upper + lower)/2;
xstart = xstart - mean_ul;
iter = iter +1;
end
xend = xend - xstart;
nmode=nmode+1;
% save a mode
for jj=1:1:xsize,
mode(jj,nmode) = xstart(jj);
end
end
% save the trend
for jj=1:1:xsize,
mode(jj,nmode+1)=xend(jj);
end
% add mode to the sum of modes from earlier ensemble members
% 1,size(allmode),2,size(mode)
allmode=allmode+mode;
%%%=============================================================
% sifting X2
xorigin = X2;
xend = xorigin;
% save the initial data into the first column
for jj=1:1:xsize,
mode(jj,1) = xorigin(jj);
end
nmode = 1;
while nmode <= TNM,
xstart = xend;
iter = 1;
while iter<=5,
[spmax, spmin, flag]=extrema(xstart);
upper= spline(spmax(:,1),spmax(:,2),dd);
lower= spline(spmin(:,1),spmin(:,2),dd);
mean_ul = (upper + lower)/2;
xstart = xstart - mean_ul;
iter = iter +1;
end
xend = xend - xstart;
nmode=nmode+1;
% save a mode
for jj=1:1:xsize,
mode(jj,nmode) = xstart(jj);
end
end
% save the trend
for jj=1:1:xsize,
mode(jj,nmode+1)=xend(jj);
end
% add mode to the sum of modes from earlier ensemble members
allmode=allmode+mode;
%fprintf(The '-');
end
% ensemble average
allmode=allmode/NE/2;
% Rescale mode to origional unit.
allmode=allmode*Ystd;
Copy the code
3. Operation results
Matlab version and references
1 matlab version 2014A
2 Reference [1] Shen Zaiyang. Proficient in MATLAB Signal Processing [M]. Tsinghua University Press, 2015. [2] GAO Baojian, PENG Jinye, WANG Lin, PAN Jianshou. Signal and System — Analysis and Implementation using MATLAB [M]. Tsinghua University Press, 2020. [3] WANG Wenguang, WEI Shaoming, REN Xin. MATLAB Implementation of Signal Processing and System Analysis [M]. Publishing House of Electronics Industry, 2018.