下面的代码可以部分达到楼主的要求,如果想要得到更加详细的变换过程,建议看懂emd.m以后,自行修改emd.m的代码来绘制。
clear
f = [ 2/32 3/32 ];
T = 128;
t = 0:T-1;
s1 = cos(2*pi*f(1)*t);
s2 = cos(2*pi*(f(2)*t+f(2)/100*t.^2));
s = s1 + s2;
N = length(s);
figure(1);
subplot(3,1,1);
plot(s1)
subplot(3,1,2);
plot(s2)
subplot(3,1,3);
plot(s)
IMF = emd(s, 'display', 1);
fn = size(IMF,1);
eng = 0;
figure;
for k = 1:fn
eng = eng + sum(IMF(k,:).^2);
subplot(fn, 1, k); hold on;
plot(IMF(k,:))
end
title('Signal decomposition');
xlabel('time');
disp(sprintf('%f %f',eng,sum(s.^2)));
[A, fa, tt] = hhspectrum(IMF);
[E, tt1] = toimage(A,fa,tt,length(tt));
disp_hhs(E, tt1);
colorbar |