声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1409|回复: 6

[HHT] 请问这个函数去哪里找?

[复制链接]
发表于 2007-12-18 21:33 | 显示全部楼层 |阅读模式

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

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

x
hilbtmf()
回复
分享到:

使用道具 举报

发表于 2007-12-18 21:40 | 显示全部楼层

回复 #1 mzy 的帖子

这是什么函数,什么功能,完成哪方面的运算?
 楼主| 发表于 2007-12-18 22:36 | 显示全部楼层

我还以为大家都明白

rc-hw-0002 的程序中的,好像是hilbert()的改进

在别人的基础上改了一下:
function [S,freq] = HHTspe(imf,N,fs);
%%N--------分辨率
%fs-------采样频率
%s--------时间-频率-幅值矩阵
if(nargin<3)
    fs=1;
end
L = size(imf,1);
S = [];
     
clear x z m p freq
   
x = imf';  
z = hilbtmf(x); % 用改进的Hilbert变换,效果好一些。
m = abs(z);
p = angle(z);

for i = 1:L
      freq(:,i) = instfreq(z(:,i))*fs; %乘以了采样频率
                  ceilfreq(:,i) = ceil(freq(:,i)*N);
            for j = 1:length(x)-2
            S(ceilfreq(j,i),j+1) = m(j+1,i);
         end
     end
%plot S
figure;
t=(1:length(x))/fs;
f=(1:size(S,1))/N; %
imagesc(t,f,S);
colorbar;
set(gca,'YDir','normal');
xlabel('Time t/s');
ylabel(' Frequency/HZ');

return

[ 本帖最后由 mzy 于 2007-12-18 22:37 编辑 ]
发表于 2007-12-18 22:39 | 显示全部楼层

这个吧

hilbtmf.m

6.06 KB, 下载次数: 33

评分

1

查看全部评分

发表于 2007-12-18 22:47 | 显示全部楼层
这个函数是哪里的?时频工具箱??
发表于 2007-12-18 22:50 | 显示全部楼层

这个

function h=hilbtmf(x)
%
%   h=hilbtmf(x):
%    Function to perform an improved Hilbert transform on data x(n,k),
%    where n specifies the length of time series, and
%    k - the number of IMF components.
%    The end effect is eliminated by extension of data by the wave,
%    which is calculated from the data points found between two extrema
%    across the zero crossing.
%    If the wave is not found (as in residue) the data is not extended.
%    The function applies smoothing the input data before processing.
%
%    Input-
% x - 2-D matrix x(n,k) of IMF components
%    Output-
% h - 2-D matrix h(n,k) of improved Hilbert transform
%
%    Z. Shen (JHU)  Jan. 1996   Initial
%    D. XIANG (JHU)  April 4, 2002 Modified
% (Extended both ends with 2 waves ending at zero crossing,
%        and both ends with the same slope.)
%    D. Xiang (JHU)  May 18, 2002 Modified
% (Added smoothing to overcome step function problem.
%        Added handling of the no wave situation.)
%    J.Marshak(NASA GSFC) Jan.16, 2004 Modified and edited
% (Replaced 'break' with 'continue' if no wave is found.)
%
%    Temporary remarks -
% The procedure stops if no wave is found for the IMF:
%       the IMFs that follow will not be processed and return the
% original data. It is the assumption that only one IMF
% (the last one) can have no detectable extrema (is the residue).
%       The suggestion is to use 'continue' instead of 'break' in order
% to pass the control to the next available IMF component or
% stop if there are none.
%----- Get dimensions
[n,kpt]=size(x);
%----- Use smoothing of x for n_mx and n_mn search
xx=zeros(n,kpt);
filtr=fir1(8,.1);
for j=1:kpt
   xx(:,j)=filtfilt(filtr,1,x(:,j));
end
%----- Process each IMF component
for j=1:kpt
    %-------------------Treat the head ----------------------------------
    indx1=0; indx2=0;
    n_mx=-1;
    n_mn=-1;
    j2=2;  
    while j2<=n-1 ,   
        if (xx(j2-1,j)<xx(j2,j))&(xx(j2,j)>=xx(j2+1,j)) % max point
            n_mx=j2;
            x_mx=xx(j2,j);
            indx1=1;
        elseif (xx(j2-1,j)>xx(j2,j))&(xx(j2,j)<=xx(j2+1,j)) % min point
            n_mn=j2;
            x_mn=xx(j2,j);
            indx2=1;
        end
        if indx1>=.9 & indx2>=.9
            break
        end
        j2=j2+1;
     end
   
    if (n_mx==-1) | (n_mn==-1)
        %----- Do Hilbert transform directly if no max or min
        x(:,j)=hilbert(x(:,j));
        continue;
    elseif n_mn<n_mx,
zz=x(n_mn:n_mx,j);
mm1=size(zz);mm=mm1(1);
ia=fix(n_mn/(2*(mm-1)))+1;
iaa=max(ia,2); %DX, modify constant from 1 to 2.
zz1=flipud(zz);
x1=zz1;
for jj=1:iaa,
   x1=[x1;zz(2:mm);zz1(2:mm)];
end
        %----- Find the first zero-crossing and the slope -DX
        [r,c]=size(x1);
        for kk=1:r-1
          if((x1(kk)*x1(kk+1))<=0)
            if(abs(x1(kk)) > abs(x1(kk+1)))
               n0=kk;
            else
               n0=kk+1;
            end
            s0=x1(kk+1)-x1(kk);
            break;
          end
        end
        x1=x1(n0:r);
      
        x1=[x1;x(n_mn+1:n,j)];
sz=max(size(x1));
np1=sz-n;
    else
zz=x(n_mx:n_mn,j);
mm1=size(zz);mm=mm1(1);
        ia=fix(n_mx/(2*(mm-1)))+1;
iaa=max(ia,2); %DX, modify constant from 1 to 2.
zz1=flipud(zz);
        x1=[zz;zz1(2:mm)];
for jj=1:iaa,
   x1=[x1;zz(2:mm);zz1(2:mm)];
        end  
        %----- Find the first zero-crossing and the slope -DX
        [r,c]=size(x1);
        for kk=1:r-1
            if((x1(kk)*x1(kk+1))<=0)
               if(abs(x1(kk)) > abs(x1(kk+1)))
                  n0=kk;
               else
                  n0=kk+1;
               end
               s0=x1(kk+1)-x1(kk);
               break;
            end
        end
        x1=x1(n0:r);
x1=[x1;x(n_mx+1:n,j)];
sz=max(size(x1));
np1=sz-n;
    end
    %---------------------Treat the tail----------------------------
    j2=n-1;
    indx1=0; indx2=0;
    while j2>=2 ,
        if (xx(j2-1,j)<xx(j2,j))&(xx(j2,j)>=xx(j2+1,j)) % max point
            n_mx=j2;
            x_mx=xx(j2,j);
            indx1=1;
        elseif (xx(j2-1,j)>=xx(j2,j))&(xx(j2,j)<xx(j2+1,j)) % min point
            n_mn=j2;
            x_mn=xx(j2,j);
            indx2=1;
        end
        if indx1>=.9 & indx2>=.9
            break
        end
        j2=j2-1;
    end

    n_mn=n_mn+np1;
    n_mx=n_mx+np1;
   
    if n_mn<n_mx,
zz=x1(n_mn:n_mx);
mm=max(size(zz));
zz1=flipud(zz);
ia=fix((sz-n_mx)/(2*(mm-1)))+1;
iaa=max(ia,2); %DX, modify constant from 1 to 2.
iaa1=iaa*2;
x1=[x1(1:n_mx);zz1(2:mm)];
for jj=1:iaa
    x1=[x1;zz(2:mm);zz1(2:mm)];
end
        x1=[x1;zz(2:mm-1)];
      
        %----- Find the first zero-crossing and the slope -DX
        [r,c]=size(x1);
        for k=1:r-1
           kk=r-k+1;
           if((x1(kk)*x1(kk-1))<=0)
           if(abs(x1(kk)) > abs(x1(kk-1)))
               n0=kk;
           else
               n0=kk-1;
           end
            
           if(((x1(kk)-x1(kk-1))*s0)>0)   %same sign as s0
               break;
           end
         end
      end
      x1=x1(1:n0);
    else
zz=x1(n_mx:n_mn);
mm=max(size(zz));
zz1=flipud(zz);
ia=fix((sz-n_mn)/(2*(mm-1)))+1;
iaa=max(ia,2); %DX, modify constant from 1 to 2.
iaa1=iaa*2;
x1=x1(1:n_mn);
for jj=1:iaa
     x1=[x1;zz1(2:mm);zz(2:mm)];
end
        x1=[x1;zz1(2:mm-1)];
        %----- Find the first zero-crossing and the slope -DX
        [r,c]=size(x1);
        for k=1:r-1
            kk=r-k+1;
            if((x1(kk)*x1(kk-1))<=0)
               if(abs(x1(kk)) > abs(x1(kk-1)))
                  n0=kk;
               else
                  n0=kk-1;
               end
            
               if(((x1(kk)-x1(kk-1))*s0)>0)   %same sign as s0
                  break;
               end
            end
        end
        x1=x1(1:n0);
    end
    %----- Apply Hilbert transform to the extended data
    x1=hilbert(x1);
    %----- Cut the extended portion
    x(:,j)=x1(np1:np1+n-1);
end
%----- Assign the output
h=x;
clear x

[ 本帖最后由 zhangnan3509 于 2007-12-19 08:53 编辑 ]
 楼主| 发表于 2007-12-19 20:03 | 显示全部楼层

谢谢大家

谢谢
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-16 19:46 , Processed in 0.072150 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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