声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 3242|回复: 16

[综合] 求助做EMD和HHT的

[复制链接]
发表于 2007-5-2 00:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
function [fnormhat,t]=instfreq(x,t,L,trace);
%INSTFREQ Instantaneous frequency estimation.
%        [FNORMHAT,T]=INSTFREQ(X,T,L,TRACE) computes the instantaneous
%        frequency of the analytic signal X at time instant(s) T, using the
%        trapezoidal integration rule.
%        The result FNORMHAT lies between 0.0 and 0.5.
%
%        X : Analytic signal to be analyzed.
%        T : Time instants                (default : 2:length(X)-1).
%        L : If L=1, computes the (normalized) instantaneous frequency
%            of the signal X defined as angle(X(T+1)*conj(X(T-1)) ;
%            if L>1, computes a Maximum Likelihood estimation of the
%            instantaneous frequency of the deterministic part of the signal
%            blurried in a white gaussian noise.
%            L must be an integer               (default : 1).
%        TRACE : if nonzero, the progression of the algorithm is shown
%                                        (default : 0).
%        FNORMHAT : Output (normalized) instantaneous frequency.
%        T : Time instants.
%
%        Examples :
%         x=fmsin(70,0.05,0.35,25); [instf,t]=instfreq(x); plot(t,instf)
%         N=64; SNR=10.0; L=4; t=L+1:N-L; x=fmsin(N,0.05,0.35,40);
%         sig=sigmerge(x,hilbert(randn(N,1)),SNR);
%         plotifl(t,[instfreq(sig,t,L),instfreq(x,t)]); grid;
%         title ('theoretical and estimated instantaneous frequencies');
%
%        See also  KAYTTH, SGRPDLAY.
%        F. Auger, March 1994, July 1995.
%        Copyright (c) 1996 by CNRS (France).
%
%        ------------------- CONFIDENTIAL PROGRAM --------------------
%        This program can not be used without the authorization of its
%        author(s). For any comment or bug report, please send e-mail to
%        f.auger@ieee.org
if (nargin == 0),
error('At least one parameter required');
end;
[xrow,xcol] = size(x);
if (xcol~=1),
error('X must have only one column');
end
if (nargin == 1),
t=2:xrow-1; L=1; trace=0.0;
elseif (nargin == 2),
L = 1; trace=0.0;
elseif (nargin == 3),
trace=0.0;
end;
if L<1,
error('L must be >=1');
end
[trow,tcol] = size(t);
if (trow~=1),
error('T must have only one row');
end;
if (L==1),
if any(t==1)|any(t==xrow),
  error('T can not be equal to 1 neither to the last element of X');
else
  fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi);
end;
else
H=kaytth(L);
if any(t<=L)|any(t+L>xrow),
  error('The relation L<T<=length(X)-L must be satisfied');
else
  for icol=1:tcol,
   if trace, disprog(icol,tcol,10); end;
   ti = t(icol); tau = 0:L;
   R = x(ti+tau).*conj(x(ti-tau));
   M4 = R(2:L+1).*conj(R(1:L));
   
   diff=2e-6;
   tetapred = H * (unwrap(angle(-M4))+pi);
   while tetapred<0.0 , tetapred=tetapred+(2*pi); end;
   while tetapred>2*pi, tetapred=tetapred-(2*pi); end;
   iter = 1;
   while (diff > 1e-6)&(iter<50),
    M4bis=M4 .* exp(-j*2.0*tetapred);
    teta = H * (unwrap(angle(M4bis))+2.0*tetapred);
    while teta<0.0 , teta=(2*pi)+teta; end;
    while teta>2*pi, teta=teta-(2*pi); end;
    diff=abs(teta-tetapred);
    tetapred=teta; iter=iter+1;
   end;
   fnormhat(icol,1)=teta/(2*pi);
  end;
end;
end;



这是求瞬时频率的程序,请问怎么修改能去掉频率限制在between 0.0 and 0.5之间?
回复
分享到:

使用道具 举报

发表于 2007-5-2 10:58 | 显示全部楼层
没必要去掉吧,这是以采样频率归一化的结果,使得与采样频率无关.
你要转化到实际的频率,再把它乘上采样频率就行了

评分

1

查看全部评分

发表于 2007-5-2 11:11 | 显示全部楼层
本帖最后由 VibInfo 于 2016-11-8 16:07 编辑
原帖由 yangzj 于 2007-5-2 10:58 发表
没必要去掉吧,这是以采样频率归一化的结果,使得与采样频率无关.
你要转化到实际的频率,再把它乘上采样频率就行了

估计楼主的意思是得到的瞬时频率看不出有何意义,这是instfreq本身的问题,这并非通过乘上采样频率可以解决的
发表于 2007-5-2 16:05 | 显示全部楼层
我同意yangzj的看法。分析此程序,最关键的一句是
fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi);
可以看出此瞬时频率没有除以采样周期deltat,可见是以采样频率归一化的结果。故The result FNORMHAT lies between 0.0 and 0.5.
但我仍然迷惑的是
0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)是用中心差分计算 arg x(t)的微分吗?
发表于 2007-5-2 23:57 | 显示全部楼层
本帖最后由 VibInfo 于 2016-11-8 16:07 编辑
原帖由 huangyong87 于 2007-5-2 16:05 发表
我同意yangzj的看法。分析此程序,最关键的一句是
fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi);
可以看出此瞬时频率没有除以采样周期deltat,可见是以采样频率归一化的结果。故The result FNORMH ...


建议自己稍微动手推导一下,这个基本上是正确的
 楼主| 发表于 2007-5-3 01:04 | 显示全部楼层
恩,我的意思就是想在谱图中看到信号的真实频率,或者以倍频的形式展现
当看到这时fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi);
就不知怎么去掉这个类似归一化的限制了
发表于 2007-5-3 11:08 | 显示全部楼层
本帖最后由 VibInfo 于 2016-11-8 16:07 编辑
原帖由 liliang 于 2007-5-3 01:04 发表
恩,我的意思就是想在谱图中看到信号的真实频率,或者以倍频的形式展现
当看到这时fnormhat=0.5*(angle(-x(t+1).*conj(x(t-1)))+pi)/(2*pi);
就不知怎么去掉这个类似归一化的限制了

乘以采样频率就可以了
发表于 2007-5-3 11:12 | 显示全部楼层

回复 #6 liliang 的帖子

我觉得咱们在以前不少帖子里不止一次说过这个问题,现在单独出一个帖子,有这个必要吗?楼主搜索过以前的帖子吗
 楼主| 发表于 2007-5-3 12:42 | 显示全部楼层

回复 #8 zhangnan3509 的帖子

看到过,本人比较笨没有看明白才又发的贴,我也是有其他原因的,希望能谅解
:@D
发表于 2007-5-21 16:51 | 显示全部楼层

我怎么觉得乘上采样频率得不到实际频率呢

比如我仿真时采样频率为10000,实际频率为500,但得到的归一化频率怎么是0.45呢?我搞不懂。有那位高手可以指点一下吗

t=0:0.0001:1;
sig=sin(1000*pi*t);
figure(2)
plot(t,sig);
h=hilbert(sig);
ifr=instfreq(h');
figure(3);
plot(t(1:1999),ifr(1:1999),'LineWidth',2);
发表于 2007-5-21 16:56 | 显示全部楼层

回复 #10 caicaicai 的帖子

俺不明白,您这是要做啥呀!要是用EMD,怎么不调用呢?
发表于 2007-5-21 17:20 | 显示全部楼层

搞掂了

谢谢啊
发表于 2007-5-21 17:23 | 显示全部楼层

回复11楼

哦,我只是想得到实际频率而已,并没用emd
发表于 2007-5-21 17:53 | 显示全部楼层

回复 #13 caicaicai 的帖子

其实用FFT就够了。
发表于 2011-11-21 11:18 | 显示全部楼层
回复 7 # eight 的帖子

直接乘以采样频率没法解决这个问题哦~~,尝试了之后再运行toimage函数时会出错的。请高手指点,谢谢~
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-4-29 15:55 , Processed in 0.060813 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表