希尔伯特频谱算法Hilbert-Huang spectral analysis(matlab代码)

前段时间磕盐接触到了希尔伯特频谱,它是一种信号分解方法,1998年提出来的,主旨是把复杂信号分解为简单信号的加权和,就像傅里叶变换小波变换一样,但是他和傅里叶变换等方法的区别是他是纯粹时间域的分解,但是每个子信号却可以表示不同的频率成分,于是可以得到像小波变换那样的时频平面,但是这个方法明显比小波分解冷门的多,而且在我的实验结果里确实远远远远弱于小波分解,不过也算是自己辛苦几天看论文和写代码的成果,特此记录,如果后面有人用到这个,可以快速入门

文献链接:The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis

伪代码,我读论文总结出来的,主要就是经验模式分解EMD和希尔伯特变换两步
在这里插入图片描述
伪代码的latex 代码

\begin{algorithm}
	\caption{Hilbert-Huang spectral analysis \cite{Branch1998}}
	\label{hhsa}
	\begin{algorithmic}[1] 
		\Require The original signal vector $\boldsymbol x$.
		\Ensure  The Hilbert-Huang Spectrum, i.e. an energy-time-frequency distribution of $\boldsymbol x$. 
		\Function{EMD}{$\boldsymbol x, SegLen, ResidueThreshold, SD_T$}		
		\State $\boldsymbol{IMF} \gets \boldsymbol 0$
		\State $i \gets 0$
		\State $ N \gets length(\boldsymbol{x}) / SegLen$
		\State $residue \gets \infty$
		\While {$residue > ResidueThreshold$}
		\State $i \gets i+1$	
		\State $\boldsymbol{x_i} \gets \boldsymbol{x}-\sum_i \boldsymbol{IMF}$
		\State $SD \gets \infty$
		\While{$SD > SD_T$}	
		\For {$j=1 \to j=N$}	
		\State $\boldsymbol{seg_{ij}} \gets \boldsymbol{x_i}[(1+(j-1)*SegLen) : (j*SegLen)]$
		\State $[LocalMax_{ij}, IndMax_{ij}]\gets max(\boldsymbol{seg_{ij}})$
		\State $IndMax_{ij}\gets IndMax_{ij}+(j-1)*SegLen$
		\State $[LocalMin_{ij}, IndMin_{ij}]\gets min(\boldsymbol{seg_{ij}})$
		\State $IndMin_{ij}\gets IndMin_{ij}+(j-1)*SegLen$
		\EndFor
		\State $\boldsymbol{UpperEnv_i} \gets spline(\boldsymbol{IndMax_i},\boldsymbol{LocalMax_i},1:length(\boldsymbol{x_i}))$
		\State $\boldsymbol{LowerEnv_i} \gets spline(\boldsymbol{IndMin_i},\boldsymbol{LocalMin_i},1:length(\boldsymbol{x_i}))$
		\State $\boldsymbol{LocalMeanApprox_i} \gets (\boldsymbol{UpperEnv_i} + \boldsymbol{LowerEnv_i})/2$
		\State $\boldsymbol {x_i} \gets \boldsymbol {x_i} - \boldsymbol{LocalMeanApprox_i} $
		
		\State $SD\gets \sum[\frac{(\boldsymbol{xTemp}-\boldsymbol{x_i})^2}{\boldsymbol{xTemp}^2}]$
		\EndWhile
		\State $\boldsymbol{IMF_i} \gets \boldsymbol x_i$
		\State $residue \gets mean(\boldsymbol x-\sum_i \boldsymbol{IMF})$
		\EndWhile
		\State \Return{$\boldsymbol{IMF}$}
		\EndFunction
		\State
		\Function{HT}{$\boldsymbol{IMF},fs$}
		\State $\boldsymbol{zt} \gets hilbert(\boldsymbol{IMF})$
		\State $\boldsymbol{Energy} \gets (imag(\boldsymbol{zt}))^2+(real(\boldsymbol{zt}))^2$
		\State $\boldsymbol{Phase} \gets arctan\frac{imag(\boldsymbol{zt})}{real(\boldsymbol{zt})+eps}$
		\State $\boldsymbol{frequency} \gets \boldsymbol{Phase}/(2*\pi*fs)$
		\State \Return{$\boldsymbol{Energy,frequency}$} 
		\EndFunction
	\end{algorithmic}
\end{algorithm}

导言区需要包含的包

\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}  
\usepackage{amsmath}  % 用于算法伪代码中的数学公式
\renewcommand{\algorithmicrequire}{ \textbf{Input:}}     %Use Input in the format of Algorithm
\renewcommand{\algorithmicensure}{ \textbf{Output:}}    %UseOutput in the format of Algorithm

matlab代码后面加,被新冠病毒阻挡了去学校的脚步,代码在教研室电脑上,后面补上

结果图
在这里插入图片描述

发布了190 篇原创文章 · 获赞 65 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_36607894/article/details/104114764