qqzhouqianziyi 发表于 2011-3-24 17:27

谁有HHT中toimage和disp_hhs的源程序

谁有HHT中toimage和disp_hhs的源程序麻烦上传一份吧 谢谢

zhuchengyan 发表于 2011-3-30 11:20

function = 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(,A(:),);

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

end

zhuchengyan 发表于 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,);
set(gca,'YDir','normal')
xlabel(['time'])
ylabel(['normalized frequency'])
title('Hilbert-Huang spectrum')

我爱振动 发表于 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;
data=z;
imf=eemd(data,0.2,100);                        
=hhspectrum(imf);      
=toimage(A,f);            disp_hhs(E);   
   

页: [1]
查看完整版本: 谁有HHT中toimage和disp_hhs的源程序