声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1718|回复: 3

[HHT] 谁有HHT中toimage和disp_hhs的源程序

[复制链接]
发表于 2011-3-24 17:27 | 显示全部楼层 |阅读模式

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

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

x
谁有HHT中toimage和disp_hhs的源程序  麻烦上传一份吧 谢谢
回复
分享到:

使用道具 举报

发表于 2011-3-30 11:20 | 显示全部楼层
function [im,tt,ff] = toimage(A,f,varargin)

DEFSPL = 400;

error(nargchk(2,5,nargin));

switch nargin
  case 2
    t = 1:size(A,2);
    sply = DEFSPL;
    splx = length(t);
  case 3
    if isscalar(varargin{1})
      t = 1:size(A,2);
      splx = length(t);
      sply = varargin{1};
    else
      t = varargin{1};
      splx = length(t);
      sply = DEFSPL;
    end
  case 4
    if isscalar(varargin{1})
      t = 1:size(A,2);
      sply = varargin{1};
      splx = varargin{2};
    else
      t = varargin{1};
      sply = varargin{2};
      splx = length(t);
    end
  case 5
    t = varargin{1};
    splx = varargin{2};
    sply = varargin{3};
end
if isvector(A)
  A = A(:)';
  f = f(:)';
end


if issparse(A) || ~isreal(A) || length(size(A)) > 2
  error('A argument must be a real matrix')
end
if issparse(f) || ~isreal(f) || length(size(f)) > 2
  error('f argument must be a real matrix')
end
if any(size(f)~=size(A))
  error('A and f matrices must have the same size')
end
if issparse(t) || ~isreal(t) || ~isvector(t) || length(t)~=size(A,2)
  error('t argument must be a vector and its length must be the number of columns in A and f inputs')
end
if ~isscalar(splx) || ~isreal(splx) || splx ~= floor(splx) || splx <= 0
  error('splx argument must be a positive integer')
end
if ~isscalar(sply) || ~isreal(sply) || sply ~= floor(sply) || sply <= 0
  error('splx argument must be a positive integer')
end

if any(diff(diff(t))) && splx ~= length(t)
  warning('toimage:nonuniformtimeinsants','When splx differs from length(t), the function only works for equally spaced time instants. You may consider reformating your data (using e.g. interpolation) before using toimage.')
end

f = min(f,0.5);
f = max(f,0);

indf = round(2*f*(sply-1)+1);
indt = repmat(round(linspace(1,length(t),splx)),size(A,1),1);
im = accumarray([indf(:),indt(:)],A(:),[sply,splx]);

indt = indt(1,:);
tt = t(indt);
ff = (0:sply-1)*0.5/sply+1/(4*sply);

end
发表于 2011-3-30 11:20 | 显示全部楼层
function disp_hhs(im,t,inf)

% DISP_HHS(im,t,inf)
% displays in a new figure the spectrum contained in matrix "im"
% (amplitudes in log).
%
% inputs : - im : image matrix (e.g., output of "toimage")
% - t (optional) : time instants (e.g., output of "toimage")
% - inf (optional) : -dynamic range in dB (wrt max)
% default : inf = -20
%
% utilisation : disp_hhs(im) ; disp_hhs(im,t) ; disp_hhs(im,inf)
% disp_hhs(im,t,inf)

figure
colormap(bone)
colormap(1-colormap);

if nargin==1
inf=-20;
t = 1:size(im,2);

end

if nargin == 2
if length(t) == 1
inf = t;
t = 1:size(im,2);
else
inf = -20;
end
end

if inf >= 0
error('inf doit etre < 0')
end

M=max(max(im));

im = log10(im/M+1e-300);

inf=inf/10;


imagesc(t,fliplr((1:size(im,1))/(2*size(im,1))),im,[inf,0]);
set(gca,'YDir','normal')
xlabel(['time'])
ylabel(['normalized frequency'])
title('Hilbert-Huang spectrum')

评分

1

查看全部评分

发表于 2014-2-26 14:22 | 显示全部楼层
zhuchengyan 发表于 2011-3-30 11:20
function disp_hhs(im,t,inf)

% DISP_HHS(im,t,inf)

你好,我想问下用网上的程序做希尔伯特谱时为什么会出现下面的图形,而不是网上的蓝色背景的图形,先谢谢了哈~
N=1000;

n=1:N;

fs=1000;

t=n/fs;

fx=10;

fy=50;

x=cos(2*pi*fx*t);

y=10*cos(2*pi*fy*t);

z=x+y;
QQ截图20140226134956.jpg

data=z;

imf=eemd(data,0.2,100);                        

[A,f,t]=hhspectrum(imf);        

[E,t,Cenf]=toimage(A,f);            
disp_hhs(E);   
     

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

本版积分规则

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

GMT+8, 2024-12-27 02:02 , Processed in 0.132596 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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