1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| % 小波包分解,重构轴承振动信号,Hilbert包络,FFT进行频谱分析 %采样频率 fs=12000; %计算其自相关序列 xdatac=xcorr(xdata); [t,d]=wpdec(xdatac,3,'db5');% Wavelet packet decomposition 1-D
%求每组系数>>>>>阈值=均值+标准方差 thr0=mean([3,0])+std([3,0]); thr1=mean([3,1])+std([3,1]); thr2=mean([3,2])+std([3,2]); thr3=mean([3,3])+std([3,3]); thr4=mean([3,4])+std([3,4]); thr5=mean([3,5])+std([3,5]); thr6=mean([3,6])+std([3,6]); thr7=mean([3,7])+std([3,7]); %THR=[thr0,thr1,thr2,thr3,thr4,thr5,thr6,thr7];
%消噪 xd0=wpdencmp([3,0],'s',3,'db5','threshold',thr0,0); xd1=wpdencmp([3,1],'s',3,'db5','threshold',thr1,0); xd2=wpdencmp([3,2],'s',3,'db5','threshold',thr2,0); xd3=wpdencmp([3,3],'s',3,'db5','threshold',thr3,0); xd4=wpdencmp([3,4],'s',3,'db5','threshold',thr4,0); xd5=wpdencmp([3,5],'s',3,'db5','threshold',thr5,0); xd6=wpdencmp([3,6],'s',3,'db5','threshold',thr6,0); xd7=wpdencmp([3,7],'s',3,'db5','threshold',thr7,0); %XD=wpdencmp([t,d],'s',3,'db5','threshold',THR,0);%用一个公式代替
%计算每组系数的能量 p0=sum(xd0^2); p1=sum(xd1^2); p2=sum(xd2^2); p3=sum(xd3^2); p4=sum(xd4^2); p5=sum(xd5^2); p6=sum(xd6^2); p7=sum(xd7^2); %找到最大的能量所对应的序数 pmax=max(p0,p1,p2,p3,p4,p5,p6,p7); if pmax==p0 xdmax=xd0; elseif pmax==p1 xdmax=xd1; elseif pmax==p2 xdmax=xd2; elseif pmax==p3 xdmax=xd3; elseif pmax==p4 xdmax=xd4; elseif pmax==p5 xdmax=xd5; elseif pmax==p6 xdmax=xd6; else xdmax=xd7; end %计算其自相关序列 rce=xcorr(xdmax); %hilbert包络&FFT频谱分析
|