|
原帖由 laughing 于 2007-6-20 11:32 发表
搞了两天,实在没弄明白,没办法,又上来求助了,实在不好意思.
以下是小弟练习作hht谱图用的小程序:
clear
fs=1000.1;%采样频率
t=0:10/1000:10;&共1001个数据点,一共采了10秒
x=exp(-0.3*t).*cos(pi*t.^2+2*pi*t) ...
LZ,注意这一句???
我直接用楼主的代码,画出来的是这样的
我记得disp_hhs的代码关于参数这一块好像有点bug,我以前修改过但忘记是哪个位置了,现贴出来,请参考。-
- %DISP_HHS display Hilbert-Huang spectrum
- % DISP_HHS(im,t,inf)
- % displays in a new figure the spectrum contained in matrix "im"
- % (amplitudes in dB).
- % 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
- % - fs: sampling frequency
- % use: disp_hhs(im) ; disp_hhs(im,t) ; disp_hhs(im,inf)
- % disp_hhs(im,t,inf) ; disp_hhs(im,inf,fs) ; disp_hhs(im,[],fs)
- % disp_hhs(im,t,[],fs) ; disp_hhs(im,t,inf,fs)
- %
- %
- % See also
- % emd, hhspectrum, toimage
- %
- % G. Rilling, last modification 3.2007
- % gabriel.rilling@ens-lyon.fr
- function disp_hhs(varargin)
- error(nargchk(1,4,nargin));
- fs = 0;
- inf = -20;
- im = varargin{1};
- t = 1:size(im,2);
- switch nargin
- case 1
- %raf
- case 2
- if isscalar(varargin{2})
- inf = varargin{2};
- else
- t = varargin{2};
- end
- case 3
- if isvector(varargin{2})
- t = varargin{2};
- inf = varargin{3};
- else
- inf = varargin{2};
- fs = varargin{3};
- end
- case 4
- t = varargin{2};
- inf = varargin{3};
- fs = varargin{4};
- end
- if isempty(inf)
- inf = -20;
- end
- if inf > 0
- inf = -inf;
- elseif inf == 0
- error('inf must be nonzero')
- end
- M=max(max(im));
- warning off
- im = 10*log10(im/M);
- warning on
- figure
- if fs == 0
- imagesc(t,[0,0.5],im,[inf,0]);
- ylabel('normalized frequency')
- else
- t=t/fs;
- imagesc(t,[0,0.5*fs],im,[inf,0]);
- ylabel('frequency')
- end
- set(gca,'YDir','normal')
- xlabel('time')
- title('Hilbert-Huang spectrum')
复制代码
是否应该是这样的?
[ 本帖最后由 bcyangbc 于 2010-4-20 16:02 编辑 ] |
-
|