还剩9页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
实现程序(源码-非Mat labHHT常珍贵)figurecolormapbonecolormap1-colormap;if nargin==1inf=-20;t=1:sizeim,2;endif nargin==2if lengtht==1inf=t;t=1:sizeim,2;elseinf=-20;endendif inf=0errorinf doitetreOendM=maxmaxim;im=log10im/M+1e-300;inf=inf/10;imagesct,fliplr1:sizeim,1/2*sizeim,1Jm,[inf,O];,setgca YDir,normar3『xlabel time]ylabel[normalized frequency]titleHilbert-Huang spectrum*function[f,z]=fftfenxit,yAL=lengtht;N=2nextpow2L;默认计算的信号是从开始的%fft0t=linspacet1,tL,N;deta=t2-t1;m=0:N-1;f=
1./N*deta*m;%下面计算的就是的傅里叶变换数值Y xt将计算出来的频谱乘以%Y=expi*4*pi*f.*ffty%得到频移后卜之间的频谱值expi*4*pi*f2,2]Y=ffty;z=sqrtY.*conjY;clear all;fs=1000000;N=lengthx;t=0:1/fs:N-1/fs;z=x;c=emdz;%计算每一个分量及最后一个剩余分量IMF与原始信号的相关性residual[m,n]=sizec;for i=1:m;a=corrcoefci,:z;5xgi=a1,2;endxg;for i=1:m-1%----------------------------------------------------------------%计算各的方差贡献率IMF%定义.方差为平方的均值减去均值的平方%均值的平方A%imfp2=meanci,:
2.25%平方的均值A%imf2p=meanci,:.2,2%各个的方差IMFA Amsei=meanci:.22-meanci:
2.2;9999end;mmse=summse;A Afor i=l:m-l msei=meanci,:.2,2-meanci,:,
2.2;%方差百分比,也就是方差贡献率msebi=msei/mmse*100;%显示各个的方差和贡献率IMFend;%画出每个分量及最后一个剩余分量IMF的图形residual figurelforvdisp[imf,int2stri];disp|msei msebi|;end;subplotm+l,l,lplott z9fsetgca/fontname/times NewRomansetgca/fontsize\
14.0ylabel|Signal*/Amplitude*I for i=l:m-lsubplotm+l,l,i+l;f fsetgcf/color/w ffplott,ci,:,k setgca,fontname,times NewRoman*setgca/fontsize\
14.0vylabel[imf Jnt2stri]end subplotm+l,l,m+l;;fsetgci7color\w plott,cm,:k fsetfgca/fontname^^imes NewRoman fsetgca/fontsize\
14.0y label[r\int2strm-1]%画出每个分量及剩余分量的幅频IMF residual曲线figure2subplotm+lj l9§etgcf7colorw|f,zl=fftt,z;;fplotf,z ksetgca/fontname7times NewRoman*setgca,fontsize,
14.0,ylabel[initial signal,int2strm-1,Amplitude]for i=1:m-1subplotm+1,1,i+1;,,,setgcf colorw55[f z]=fftt,ci:;55;plotf zk5,setgca fontnametimes NewRoman*55setgca,fontsize,
14.0,,ylabel[imf int2stri,Amplitude]5endsubplotm+1,1-1;ITH5setgcf color7w5[f,z]=fftt,cm,:;plotfzk,setgca,fontname7times NewRoman,,setgca,fontsize,
14.0,1ylabel[r,,int2strm-1/Amplitude]hx=hilbertz;xr=realhx;xi=imaghx;%计算瞬时振幅A Asz=sqrtxr.2+xi.2;%计算瞬时相位sx=anglehx;%^算瞬时频率Idt=difft;dx=diffsx;sp=dx./dt;figure6plott1:N-1,sp世瞬时频率,Ie%计算时频谱和边际谱HHT[A,fa,tt]=hhspectrumc;[E,tt1]=toimageA fatt,lengthtt;Jfigure3%二维图显示时频谱,是disp_hhsE,tt1HHT E求得的谱HHT pausefigure4fori=1:sizec15faa=fai,:;』三维图显示时[FA,TT1]=meshgridfaa t1;%HHT频图surfFA,TT1,E时频谱三维显示titleHHThold onendholdoffE=flipudE;for k=1:sizeE,1bjpk=sumEk,:*1/fs;endf=1:N-2/N*fs/2;figure5plotf,bjp;濒率xlabel/Hz;信号幅值;ylabelC信号边际谱》%要求边际谱必须先对信号进titled行分解EMDfunction[A,f,tt]=hhspectrumx,t laff55errornargchk1,4,nargin;if nargin2t=1:sizex,2;endif nargin31=1;endif nargin4aff=0;endif minsizex==1if sizex,2==1x=x;if nargin2t=1:sizex,2;endendNmodes=1;elseNmodes=sizex,1;end⑴;length tt=tl+1:lt-l;fori=1:Nmodes ani,:=hilbertxi,:;fi:=instfreqani:tt,l,;A=absan:,l+1:end-l;J53if affdisprogi,Nmodes maxNmodes100end end55function disp_hhsim,t,inf%DISP_HHSim tinf55%displays ina newfigure thespectrum%amplitudes inlog.%%inputs:-im:image matrixe.g.,output of%-t optional:time instantse.g.,output of%-inf optional:-dynamic rangein dBwrt max%default:inf=-20%%utilisation:disp_hhsim;disp_hhsim,t;disp_hhsim,inf%disp_hhsim,tjnf。
个人认证
优秀文档
获得点赞 0