www.pudn.com > 1.rar > cai.m, change:2011-04-02,size:7591b

```clc
clear all
% SampleFrequency=20000;%采样频率
% N=20480;%数据点数
x=Z1(1480:1991);
N=length(x);
fs=1;
% fs=SampleFrequency;
% x=data(:,1);
% x=x-mean(x);
% cd('C:\Program Files\MATLAB71\work\新建文件夹');
% i=1464;
%     proj_number = num2str(i);
%     proj_suffix = ').txt';
%     filename = [proj_header proj_number proj_suffix];
%      fs=12000;
%      N=32768;
%     f=(0:N/2-1)/N*fs;
%读数据的程序

%画时域波形
t=(1:N)/fs;
figure('name','时域波形');
plot(t,x);%时域波形
xlabel('时间');
ylabel('幅值');
%用zoomfft查找转频
% [Fx,Fy] = ZOOMFFT(x,fs,25,40);
% figure;
%  plot(Fx,Fy);
% xlabel('频率');
% ylabel('幅值');

% 线性相关分析1：直接调用相关计算的函数
% y=xcorr(x);
% y=y(1:N);
% y=flipud(y);
% for k=1:N
%    y(k)=y(k)/(N-k+1);
% end
% t=(1:N)/fs;
% figure;
% plot(t, y);
% xlabel('time/s');
% ylabel('amp/mv');
% title('相关函数：调用函数计算');
% y=fft(y,N)/N;
% y=2*abs(y(1:N/2));
% fx=(1:N/2)/N*fs;
% figure('name','自功率谱');
% plot(fx,y);
% xlabel('频率');
% ylabel('幅值');
%画频域波形
% y1=fft(x,N)/N;
% y=2*abs(y1(1:N/2));
% fx=(1:N/2)/N*fs;
% figure('name','频域波形');
% plot(fx,y);
% xlabel('频率');
% ylabel('幅值');
%hilbert解调后画频域波形
% h=abs(hilbert(x));
% H=h-mean(h);
% y1=fft(H,N)/N;
% y=2*abs(y1(1:N/2));
% fx=(1:N/2)/N*fs;
% figure('name','hilbert解调频域波形');
% plot(fx,y);
% xlabel('频率');
% ylabel('幅值');
% %zoomfft查找故障特征频率
% [Fx,Fy] = ZOOMFFT(H,fs,55,75);
% figure('name','hilbert解后zoomFFT频域波形');
% plot(Fx,Fy);
% xlabel('频率');
% ylabel('幅值');
%% 3层小波包分解
s=x;
[c1,d1]=general2nddecm(s);
[d21,d22]=general2nddecm(c1);
[d23,d24]=general2nddecm(d1);
[d31,d32]=general2nddecm(d21);
[d33,d34]=general2nddecm(d22);
[d35,d36]=general2nddecm(d23);
[d37,d38]=general2nddecm(d24);
[d41,d42]=general2nddecm(d31);
[d43,d44]=general2nddecm(d32);
[d45,d46]=general2nddecm(d33);
[d47,d48]=general2nddecm(d34);
[d49,d410]=general2nddecm(d35);
[d411,d412]=general2nddecm(d36);
[d413,d414]=general2nddecm(d37);
[d415,d416]=general2nddecm(d38);
for i=1:
%% 四层小波包信号重构
d410(1:length(d41))=0;
d420(1:length(d42))=0;
d430(1:length(d43))=0;
d440(1:length(d44))=0;
d450(1:length(d45))=0;
d460(1:length(d46))=0;
d470(1:length(d47))=0;
d480(1:length(d48))=0;
d490(1:length(d49))=0;
d4100(1:length(d410))=0;
d4110(1:length(d411))=0;
d4120(1:length(d412))=0;
d4130(1:length(d413))=0;
d4140(1:length(d414))=0;
d4150(1:length(d415))=0;
d4160(1:length(d416))=0;
%% 三层小波包信号重构
d310(1:length(d31))=0;
d320(1:length(d32))=0;
d330(1:length(d33))=0;
d340(1:length(d34))=0;
d350(1:length(d35))=0;
d360(1:length(d36))=0;
d370(1:length(d37))=0;
d380(1:length(d38))=0;
d210(1:length(d21))=0;
d220(1:length(d22))=0;
d230(1:length(d23))=0;
d240(1:length(d24))=0;
c10(1:length(c1))=0;
d10(1:length(d1))=0;
%dr41
[data41]=general2ndre(d41,d420);
[data41]=general2ndre(data41,d320);
[data41]=general2ndre(data41,d220);
[dr41]=general2ndre(data41,d10);
%dr42
[data42]=general2ndre(d410,d42);
[data42]=general2ndre(data42,d320);
[data42]=general2ndre(data42,d220);
[dr42]=general2ndre(data42,d10);
%dr43
[data43]=general2ndre(d43,d440);
[data43]=general2ndre(d310,data43);
[data43]=general2ndre(data43,d220);
[dr43]=general2ndre(data43,d10);
%dr44
[data44]=general2ndre(d430,d44);
[data44]=general2ndre(d310,data44);
[data44]=general2ndre(data44,d220);
[dr44]=general2ndre(data44,d10);
%dr45
[data45]=general2ndre(d45,d460);
[data45]=general2ndre(data45,d340);
[data45]=general2ndre(d210,data45);
[dr45]=general2ndre(data45,d10);
%dr46
[data46]=general2ndre(d450,d46);
[data46]=general2ndre(data46,d340);
[data46]=general2ndre(d210,data46);
[dr46]=general2ndre(data46,d10);
%dr47
[data47]=general2ndre(d47,d480);
[data47]=general2ndre(d330,data47);
[data47]=general2ndre(d210,data47);
[dr47]=general2ndre(data47,d10);
%dr48
[data48]=general2ndre(d470,d48);
[data48]=general2ndre(d330,data48);
[data48]=general2ndre(d210,data48);
[dr48]=general2ndre(data48,d10);
%dr49
[data49]=general2ndre(d49,d4100);
[data49]=general2ndre(data49,d360);
[data49]=general2ndre(data49,d240);
[dr49]=general2ndre(c10,data49);
%dr410
[data410]=general2ndre(d490,d410);
[data410]=general2ndre(data410,d360);
[data410]=general2ndre(data410,d240);
[dr410]=general2ndre(c10,data410);
%dr411
[data411]=general2ndre(d411,d4120);
[data411]=general2ndre(d350,data411);
[data411]=general2ndre(data411,d240);
[dr411]=general2ndre(c10,data411);
%dr412
[data412]=general2ndre(d4110,d412);
[data412]=general2ndre(d350,data412);
[data412]=general2ndre(data412,d240);
[dr412]=general2ndre(c10,data412);
%dr413
[data413]=general2ndre(d413,d4140);
[data413]=general2ndre(data413,d380);
[data413]=general2ndre(d230,data413);
[dr413]=general2ndre(c10,data413);
%dr414
[data414]=general2ndre(d4130,d414);
[data414]=general2ndre(data414,d380);
[data414]=general2ndre(d230,data414);
[dr414]=general2ndre(c10,data414);
%dr415
[data415]=general2ndre(d415,d4160);
[data415]=general2ndre(d370,data415);
[data415]=general2ndre(d230,data415);
[dr415]=general2ndre(c10,data415);
%dr416
[data416]=general2ndre(d4150,d416);
[data416]=general2ndre(d370,data416);
[data416]=general2ndre(d230,data416);
[dr416]=general2ndre(c10,data416);
% % dr31
% [data31]=general2ndre(d31,d320);
% [data31]=general2ndre(data31,d220);
% [dr31]=general2ndre(data31,d10);
% %myhilbert(dr31);
% % dr32
% [data32]=general2ndre(d310,d32);
% [data32]=general2ndre(data32,d220);
% [dr32]=general2ndre(data32,d10);
% %myhilbert(dr32);
% % dr33
% [data33]=general2ndre(d33,d340);
% [data33]=general2ndre(d210,data33);
% [dr33]=general2ndre(data33,d10);
% myhilbert(dr33);
% % dr34
% [data34]=general2ndre(d330,d34);
% [data34]=general2ndre(d210,data34);
% [dr34]=general2ndre(data34,d10);
% %myhilbert(dr34);
% % dr35
% [data35]=general2ndre(d35,d360);
% [data35]=general2ndre(data35,d240);
% [dr35]=general2ndre(c10,data35);
% %myhilbert(dr35);
% % dr36
% [data36]=general2ndre(d350,d36);
% [data36]=general2ndre(data36,d240);
% [dr36]=general2ndre(c10,data36);
% myhilbert(dr36);
% % dr37
% [data37]=general2ndre(d37,d380);
% [data37]=general2ndre(d230,data37);
% [dr37]=general2ndre(c10,data37);
% %myhilbert(dr37);
% % dr38
% [data38]=general2ndre(d370,d38);
% [data38]=general2ndre(d230,data38);
% [dr38]=general2ndre(c10,data38);
% %myhilbert(dr38);
figure()
% subplot(4,2,1)
plot(dr41)
% ylabel('d31')
% subplot(4,2,3)
% plot(dr32)
% %ylabel('d32')
% subplot(4,2,5)
% plot(dr33)
% ylabel('d33')
% subplot(4,2,7)
% plot(dr34)
% ylabel('d34')
% subplot(4,2,2)
% plot(dr35)
% ylabel('d35')
% subplot(4,2,4)
% plot(dr36)
% ylabel('d36')
% subplot(4,2,6)
% plot(dr37)
% ylabel('d37')
% subplot(4,2,8)
% plot(dr38)
% ylabel('d38')
% % % % -----------求解信息熵--------------
% % % c=[dr31;dr32;dr33;dr34;dr35;dr36;dr37;dr38];
% % % n=10;
% % % m=size(c,2)/n;
% % % for i=1:size(c,1)
% % %     for j=1:n
% % %         xx=c(i,(m*(j-1)+1):(m*j));
% % %         Ex(i,j)=sum(xx.^2);
% % %     end
% % %     Exn(i)=sum(Ex(i,:));
% % %     for j=1:n
% % %         p(j)=Ex(i,j)/Exn(i);
% % %     end
% % %     E(i)=-sum(p.*log(p));
% % % end
% % % E=E';
% % % Et(:,k)=E;
% % % end
% % % tsc
% % % fsc
% % % Et
% % % fsca=fsc/1000
% % %
%
%

```