%
% 原始信号图
clear all;
tic
N=5000;
fid=fopen('D:\气固实验\20130830\1_13-08-30_1427.lvm','r');
data=fscanf(fid,'%f %f %f',[3,N]);
fclose(fid);
a=5000;
i=1;
for j=1:N
y(j)=data(2,i);
i=i+1;
end
IMF = emd(y,'STOP',[0.1,0.5,0.05],'MAXITERATIONS',100);
for s=1:8
e(s)=0;
end
for i=1:8
subplot(8,1,i);plot(IMF(i,1:N))
xlabel('Sample number');ylabel('imf(i)');
hold on
for j=1:N/2
e(i)=e(i)+IMF(i,j)^2;
end
end
hold off
n=0:(N-1);
yy=zeros(11,N);
fs=20000;
for i=1:8
yy(i,:)=fft(IMF(i,1:N),N).^2;%进行fft变换
mag(i,:)=10*log10(abs(yy(i,:))/N);%求幅值
f(1,:)=n*fs/N;%进行对应的频率转换
subplot(8,1,i);plot(mag(i,1:N/2))
xlabel('Sample number');ylabel('imf(i)');
hold on
end
%plot(f(1,1:N/4),mag(1,1:N/4),'b'),xlabel('frequency/Hz'),ylabel('magnitude/dB');
hold on;
% [A,f,tt] = hhspectrum(IMF(1,1:N/2));
%[A,f,tt] = hhspectrum(IMF(1,1:N/2),1:N/2,2,1)
%下面xx第一行为纯气体160qi.lvm时的能量,其余分别为160-04.lvm,160-06.lvm,160-08.lvm,160-10.lvm,160-12.lvm,160-14.lvm对应的能量
% xx=[0.1557 0.0819 0.2992 0.2051 0.2302 0.6659 2.3436 3.9345
% 1.1858 2.4549 5.3483 1.3062 0.4868 0.0885 0.0308 0.0164
% 1.9932 1.3211 5.7204 2.3620 0.6431 0.0833 0.0343 0.0206
% 3.3051 6.9757 13.7533 5.0004 1.8452 0.3191 0.0834 0.0325
% 1.8856 2.2196 10.9447 3.9876 0.9545 0.1423 0.0582 0.0495
% 5.4210 8.1392 13.8537 6.1730 2.1568 0.3540 0.1492 0.0413
% 4.1692 15.1211 17.6479 4.6865 0.5930 0.1780 0.1046 0.0835];
%下面xx第一行为160-04.lvm,其余分别对应160-06.lvm,160-08.lvm,160-10.lvm,160-12.lvm,160-14.lvm对应的能量
xx=[1.1858 2.4549 5.3483 1.3062 0.4868 0.0885 0.0308 0.0164
1.9932 1.3211 5.7204 2.3620 0.6431 0.0833 0.0343 0.0206
3.3051 6.9757 13.7533 5.0004 1.8452 0.3191 0.0834 0.0325
1.8856 2.2196 10.9447 3.9876 0.9545 0.1423 0.0582 0.0495
5.4210 8.1392 13.8537 6.1730 2.1568 0.3540 0.1492 0.0413
4.1692 15.1211 17.6479 4.6865 0.5930 0.1780 0.1046 0.0835];
%下面x第一行为纯气体180qi.lvm时的能量,其余分别为180-04.lvm,180-06.lvm,180-08.lvm,180-10.lvm,180-12.lvm,180-14.lvm对应的能量
% yy=[ 0.1565 0.1657 0.7681 0.2220 0.1107 0.0819 0.3203 1.1921
% 2.4911 5.6120 14.6321 2.4591 0.4878 0.2434 0.0904 0.3636
% 4.9894 29.5478 14.7096 4.8315 0.7573 0.1984 0.0473 0.0491
% 4.3500 6.2183 9.0493 2.6278 0.6479 0.0895 0.0254 0.0133
% 3.7452 7.8616 12.9429 3.1946 0.6175 0.1280 0.0861 0.0351
% 4.1040 10.9830 34.0595 7.4479 1.4461 0.2210 0.1074 0.1072
% 3.2659 9.6530 19.3695 5.4594 0.6769 0.1474 0.0668 0.0617];
%下面yy第一行为180-04.lvm,其余分别为180-06.lvm,180-08.lvm,180-10.lvm,180-12.lvm,180-14.lvm对应的能量
yy=[2.4911 5.6120 14.6321 2.4591 0.4878 0.2434 0.0904 0.3636
4.9894 29.5478 14.7096 4.8315 0.7573 0.1984 0.0473 0.0491
4.3500 6.2183 9.0493 2.6278 0.6479 0.0895 0.0254 0.0133
3.7452 7.8616 12.9429 3.1946 0.6175 0.1280 0.0861 0.0351
4.1040 10.9830 34.0595 7.4479 1.4461 0.2210 0.1074 0.1072
3.2659 9.6530 19.3695 5.4594 0.6769 0.1474 0.0668 0.0617];
%下面pp第一行为纯气体200qi.lvm时的能量,其余分别为200-04.lvm,200-06.lvm,200-08.lvm,200-10.lvm,200-12.lvm,200-14.lvm对应的能量
% pp=[ 0.2388 0.2707 0.7401 0.1974 0.0343 0.0110 0.0173 0.0041
% 3.5427 2.9126 11.0343 4.4786 1.0575 0.1246 0.0434 0.0375
% 3.9603 10.7717 10.6733 3.5390 1.0177 0.1463 0.0249 0.0210
% 6.9275 17.5773 19.1440 6.1784 0.9179 0.1258 0.0905 0.0870
% 11.8565 39.7163 36.3775 11.0373 0.8550 0.3733 0.1007 0.1539
% 6.5127 26.0446 26.4164 6.3036 0.7658 0.2413 0.0937 0.0297
% 6.6340 22.4912 37.4652 12.2127 1.1458 0.3467 0.1102 0.0716];
%下面pp第一行为200-04.lvm的能量,其余分别为200-06.lvm,200-08.lvm,200-10.lvm,200-12.lvm,200-14.lvm对应的能量
pp=[ 3.5427 2.9126 11.0343 4.4786 1.0575 0.1246 0.0434 0.0375
3.9603 10.7717 10.6733 3.5390 1.0177 0.1463 0.0249 0.0210
6.9275 17.5773 19.1440 6.1784 0.9179 0.1258 0.0905 0.0870
11.8565 39.7163 36.3775 11.0373 0.8550 0.3733 0.1007 0.1539
6.5127 26.0446 26.4164 6.3036 0.7658 0.2413 0.0937 0.0297
6.6340 22.4912 37.4652 12.2127 1.1458 0.3467 0.1102 0.0716];
%下面qq第一行为纯气体220qi.lvm时的能量,其余分别为220-04.lvm,220-06.lvm,220-08.lvm,220-10.lvm,220-12.lvm,220-14.lvm对应的能量
% qq=[0.5028 1.8885 2.1736 0.3812 0.0321 0.0288 0.0713 0.0402
% 4.5165 10.9606 11.3198 3.0426 0.5506 0.0557 0.0382 0.0302
% 3.8929 9.9368 11.5174 4.0780 1.2600 0.0819 0.0831 0.0278
% 6.5046 38.6964 37.2173 9.1889 2.0689 0.3389 0.1175 0.1097
% 7.8307 18.7062 22.6451 10.6723 2.8526 0.3392 0.1683 0.0469
% 7.1018 26.2049 51.9871 10.9670 1.4781 0.2772 0.1438 0.0497
% 17.2807 42.1048 33.3042 12.6051 1.7359 0.4496 0.1921 0.0802];
%下面qq第一行为220-04.lvm时的能量,其余分别为220-06.lvm,220-08.lvm,220-10.lvm,220-12.lvm,220-14.lvm对应的能量
qq=[4.5165 10.9606 11.3198 3.0426 0.5506 0.0557 0.0382 0.0302
3.8929 9.9368 11.5174 4.0780 1.2600 0.0819 0.0831 0.0278
6.5046 38.6964 37.2173 9.1889 2.0689 0.3389 0.1175 0.1097
7.8307 18.7062 22.6451 10.6723 2.8526 0.3392 0.1683 0.0469
7.1018 26.2049 51.9871 10.9670 1.4781 0.2772 0.1438 0.0497
17.2807 42.1048 33.3042 12.6051 1.7359 0.4496 0.1921 0.0802];
%下面zz第一行为纯气体240qi.lvm时的能量,其余分别为240-04.lvm,240-06.lvm,240-08.lvm,240-10.lvm,240-12.lvm,240-14.lvm对应的能量
% zz=[0.8861 1.6501 3.8841 0.8246 0.1493 0.0482 0.0263 0.0316
% 5.5702 30.1299 30.1912 12.2940 2.8503 0.2719 0.1856 0.1066
% 5.5210 11.6126 18.8765 6.0904 0.4419 0.1180 0.0650 0.0574
% 8.5545 18.0467 37.6070 17.5106 5.0766 0.5941 0.2950 0.1632
% 12.0960 19.6357 31.1792 11.6064 1.1281 0.3276 0.0993 0.0764
% 9.8989 29.1450 46.4787 16.0806 1.9893 0.4366 0.1418 0.0416
% 14.4190 34.0124 69.1492 32.9656 3.0463 0.5463 0.1132 0.0657];
%下面zz第一行为240-04.lvm时的能量,其余分别为240-06.lvm,240-08.lvm,240-10.lvm,240-12.lvm,240-14.lvm对应的能量
zz=[5.5702 30.1299 30.1912 12.2940 2.8503 0.2719 0.1856 0.1066
5.5210 11.6126 18.8765 6.0904 0.4419 0.1180 0.0650 0.0574
8.5545 18.0467 37.6070 17.5106 5.0766 0.5941 0.2950 0.1632
12.0960 19.6357 31.1792 11.6064 1.1281 0.3276 0.0993 0.0764
9.8989 29.1450 46.4787 16.0806 1.9893 0.4366 0.1418 0.0416
14.4190 34.0124 69.1492 32.9656 3.0463 0.5463 0.1132 0.0657];
sum1=0;sum2=0;sum3=0;sum4=0;sum5=0;%能量求和
s=6;
for k=1:8
sum1=sum1+xx(s,k);
sum2=sum2+yy(s,k);
sum3=sum3+pp(s,k);
sum4=sum4+qq(s,k);
sum5=sum5+zz(s,k);
end
sum1
sum2
sum3
sum4
sum5
En1=0; En2=0; En3=0; En4=0; En5=0;%能量熵
for t=1:8
p1(t)=xx(1,t)/sum1;